SSM框架+jsp+mysql入门案例之一 登录注册功能

这是一个基于SSM(Spring、SpringMVC、MyBatis)框架,结合jsp和mysql的入门级实战案例,涵盖了登录注册功能的实现。案例中详细介绍了配置文件如applicationContext.xml、springmvc.xml等,以及数据库设计和各层代码结构,包括User实体类、DAO、Service、Controller及视图页面。
摘要由CSDN通过智能技术生成

            学完ssm框架后的入门案例一:注册登录功能.如果登录页面觉得low,自己可以使用我写好的登录页面,具体效果页面在下面.

            1.运行环境:

  • jdk1.8
  • Tomcat 8.5
  • IDEA
  • MAVEN
  • MYSQL                         

             2.目录结构

red.html和test包与此项目无关,懒得删了.

 

             3.  配置文件

     applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx.xsd">



    <!--开启注解扫描,仅不扫描Controller-->
    <context:component-scan base-package="it.cast">
            <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        </context:component-scan>


    <!--spring整合mybatis框架-->
    <!--配置连接池-->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
        <property name="jdbcUrl" value="jdbc:mysql:///ssm"/>
        <property name="user" value="root"/>
        <property name="password" value="123456"/>
    </bean>




<!--配置sqlsessionfactory工厂-->
    <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--配置StudentDao接口所在包-->

<bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="it.cast.dao"/>

</bean>

    <!--配置声明式事务管理-->
    <!--配置事务管理-->
    <bean id="transactionManager " class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!--配置事务通知-->
    <tx:advice id="txAdvice" transaction-manager="transactionManager " >
        <tx:attributes>
            <!--从这一点设置的时间点开始(时间点a)到这个事务结束的过程中,其他事务所提交的数据,该事务将看不见!(查询中不会出现别人在时间点a之后提交的数据)-->
            <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
            <tx:method name="select*" propagation="SUPPORTS" read-only="true"/>


            <tx:method name="*" isolation="DEFAULT"/>
        </tx:attributes>
    </tx:advice>
    <!--增强aop-->
<aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* it.cast.service.*ServiceImpl.*(..))"/>

</aop:config>
</beans>

log4j.properties

# Global logging configuration
log4j.rootLogger=DEBUG, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值