SpringMVC+Spring+Mybatis实现最简单的登录验证 |
您所在的位置:网站首页 › springmvc登录实现 › SpringMVC+Spring+Mybatis实现最简单的登录验证 |
SpringMVC+Spring+Mybatis实现最简单的登录验证
1.导入项目相关的jar包
db.properties: jdbc.driver=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://127.0.0.1:3306/test1jdbc.username=rootjdbc.password=#定义初始连接数jdbc.initialSize=0#定义最大连接数jdbc.maxActive=20#定义最大空闲jdbc.maxIdle=20#定义最小空闲jdbc.minIdle=1#定义最长等待时间jdbc.maxWait=60000
log4j.properties: #定义LOG输出级别log4j.rootLogger=INFO,Console,File#定义日志输出目的地为控制台log4j.appender.Console=org.apache.log4j.ConsoleAppenderlog4j.appender.Console.Target=System.out#可以灵活地指定日志输出格式,下面一行是指定具体的格式log4j.appender.Console.layout = org.apache.log4j.PatternLayoutlog4j.appender.Console.layout.ConversionPattern=[%c] - %m%n#文件大小到达指定尺寸的时候产生一个新的文件log4j.appender.File = org.apache.log4j.RollingFileAppender#指定输出目录log4j.appender.File.File = logs/ssm.log#定义文件最大大小log4j.appender.File.MaxFileSize = 10MB# 输出所以日志,如果换成DEBUG表示输出DEBUG以上级别日志log4j.appender.File.Threshold = ALLlog4j.appender.File.layout = org.apache.log4j.PatternLayoutlog4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH:mm:ss}][%c]%m%n
spring-mybatis.xml:
spring-mvc.xml: text/html;charset=UTF-8
Account.Java ![]() ![]() AccountDao.java ![]() ![]() accountMapping.xml
select * from account where id = #{id}select * from account where acc = #{name}
AccountController.java ![]() ![]() web.xml weblogin.jspcontextConfigLocationclasspath:spring-mybatis.xmlencodingFilterorg.springframework.web.filter.CharacterEncodingFiltertrueencodingUTF-8encodingFilter/*org.springframework.web.context.ContextLoaderListenerSpringMVCorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:spring-mvc.xmlSpringMVC*.do 4.数据库数据库字段以及数据信息: login.jsp Login账号:密码:${msg } showAccount.jsp
Account测试ID:${acc.id }USER:${acc.user }PAW:${acc.paw }AGE:${acc.age } 6.测试将项目添加到服务器,小编用的是Tomcat在浏览器中输入一下网址访问: http://localhost:8080/项目名称/account/toLogin.do效果图: 输入数据库中保存的账号和密码登录成功效果:
在过程中,小编遇到了两个BUG,都是因为缺少jar包引起的错误,若您也遇到相同的报错信息可以往这方面想,一下是小编的报错信息(仅供参考): 以上解决方案:缺少 commons-fileupload-1.3.2.jar 以上解决方案:缺少 jackson-mapper-asl-1.9.13.jar 和 jackson-core-asl-1.9.13.jar 以上就是小编这次的SSM(SpringMVC+Spring+Mybatis)学习之旅!如果有大神看到有哪里不好的地方,希望您告诉小编改进改进! 注:以上的配置文件是小编收集整理起来的,并非全部原创,感谢分享的博主。 MyBatis入门学习教程 http://www.linuxidc.com/Linux/2015-02/113771.htm Java实战应用:Mybatis实现单表的增删改 http://www.linuxidc.com/Linux/2014-06/103456.htm Mybatis调用PostgreSQL存储过程实现数组入参传递 http://www.linuxidc.com/Linux/2016-09/135541.htm [Java][Mybatis]物理分页实现 http://www.linuxidc.com/Linux/2014-04/99889.htm Mybatis快速入门教程 http://www.linuxidc.com/Linux/2013-06/85762.htm Mybatis入门程序 http://www.linuxidc.com/Linux/2016-07/133637.htm MyBatis中映射文件和实体类的关联性 http://www.linuxidc.com/Linux/2016-09/134942.htm Mybatis的关于批量数据操作的测试 http://www.linuxidc.com/Linux/2012-05/60863.htm Mybatis中对List 对象List的批处理插入操作 http://www.linuxidc.com/Linux/2014-02/96916.htm MyBatis 的详细介绍:请点这里MyBatis 的下载地址:请点这里 本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-02/140411.htm ![]() |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |