SSM实现简单登录注册
重构了一下以前的SSM登录注册案例,SSM的三大核心IOC,AOP,DI不用多说,网上随便翻一下都有 ,本篇直接上手,使用Maven工程搭建一个简单的SSM框架实现简单的登录注册,验证重名功能,适合刚上手的朋友看看
数据库就不贴了,俩字段,username和userpwd,指定username为主键
项目结构图

web.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee%20http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>LogAndReg</display-name>
<!-- DispatcherServlet -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 加载spring核配置文件及springmvc配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 配置编码过滤器 ps:tomcat8.0及以后的版本中,对于get请求所提交的参数会进行自动编码处理,而对于post请求没有进行编码处理-->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
springmvc.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans%20http://www.springframework.org/schema/beans/spring-beans.xsd%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20http://www.springframework.org/schema/mvc%20http://www.springframework.org/schema/mvc/spring-mvc.xsd%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20http://www.springframework.org/schema/context%20http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 放行静态资源 -->
<mvc:default-servlet-handler />
<!-- 注解驱动,识别注解 -->
<mvc:annotation-driven><

2073

被折叠的 条评论
为什么被折叠?



