SSM框架 用户登录+注册+修改密码+短信验证码验证

这篇博客记录了一个使用SSM框架(Spring、SpringMVC、MyBatis)开发的小项目,实现了用户登录、注册新用户、修改密码等功能。项目包括配置Spring相关文件、数据库连接、Mapper接口、Service层实现、Controller层控制以及验证码工具类和JSP页面展示。通过SendUtil类连接第三方平台发送短信验证码,增强安全性。
摘要由CSDN通过智能技术生成

 

记录自己的日常自学成果,防止下次又被我删了

ssm小项目:实现用户登录 、注册新用户、修改密码功能

项目结构:

具体搭建步骤:

创建c_user表:

-- auto-generated definition
create table c_user
(
	userNo int auto_increment
		primary key,
	userName varchar(20) not null,
	pass varchar(20) not null,
	address varchar(50) not null,
	phoneNum varchar(20) not null,
	price varchar(20) not null,
	createTime timestamp default CURRENT_TIMESTAMP not null comment '创建时间'
)
;

1.配置spring相关文件,创建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"
       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">

    <context:annotation-config/>

    <!-- 配置component所在的包,自动加载需要管理的Bean -->
    <context:component-scan base-package="dao,service,utils"/>

    <import resource="spring-mybatis.xml"/>

</beans>

​

2.spring-mvc.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:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.1.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

    <mvc:annotation-driven/>

    <!--组件扫描,可以扫描service,controllers,...
    这里扫描controllers-->
    <context:component-scan base-package="controllers"/>

    <!--视图解析器
    解析jsp,默认使用jstl标签,classpath下得有jstl包-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="suffix" value=""/>
        <property name="prefix" value=""/>
    </bean>

</beans>

3.spring-mybatis.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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="configurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
            </list>
        </property>
    </bean>

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClassName}"/>
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="minPoolSize" value="${c3p0.minPoolSize}"/>
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}"/>
        <property name="acquireIncrement" value="${c3p0.acquireIncrement}"/>
        <property name="acquireRetryAttempts" value="${c3p0.acquireRetryAttempts}"/>
        <property name="acquireRetryDelay" value="${c3p0.acquireRetryDelay}"/>
        <property name="autoCommitOnClose" value="${c3p0.autoCommitOnClose}"/>
        <property name="checkoutTimeout" value="${c3p0.checkoutTimeout}"/>
        <property name="idleConnectionTestPeriod" value="${c3p0.idleConnectionTestPeriod}"/>
        <property name="maxIdleTime" value="${c3p0.maxIdleTime}"/>
        <property name="testConnectionOnCheckin" value="${c3p0.testConnectionOnCheckin}"/>
        <property name="maxStatements" value="${c3p0.maxStatements}"/>
        <property name="maxStatementsPerConnection" value="${c3p0.maxStatementsPerConnection}"/>
        <property name="unreturnedConnectionTimeout" value="${c3p0.unreturnedConnectionTimeout}"/>
    </bean>

    <!-- 配置mybatis SqlSessionFactoryBean -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <propert
  • 21
    点赞
  • 147
    收藏
    觉得还不错? 一键收藏
  • 43
    评论
评论 43
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值