资源简介

Spring+SpringMVC+Mybatis最简单的整合示例,希望对大家有所帮助。

资源截图

代码片段和文件信息

package test.actions;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import test.services.UserServices;

@Controller
public class WebAction {
@Autowired
private UserServices userServices;

@RequestMapping(value = “/index“)
public String index() {
return “index“;
}

@RequestMapping(value = “/login“ method = RequestMethod.POST)
public String login(@RequestParam(“username“) String username
@RequestParam(“password“) String password ModelMap model) {
if (!userServices.isUserExist(username)) {
model.addAttribute(“msg“ “用户名不存在!“);
} else {
if (password.equals(userServices.getPasswordByUsername(username))) {
model.addAttribute(“msg“ “登录成功!“);
} else {
model.addAttribute(“msg“ “密码错误!“);
}
}
return “index“;
}

@RequestMapping(value = “/register“ method = RequestMethod.POST)
public String register(@RequestParam(“username“) String username
@RequestParam(“password“) String password ModelMap model) {
if (userServices.isUserExist(username)) {
model.addAttribute(“msg“ “用户名已存在!“);
} else {
userServices.addUser(username password);
model.addAttribute(“msg“ “注册成功!“);
}
return “index“;
}

@RequestMapping(value = “/modifyPassword“ method = RequestMethod.POST)
public String modifyPassword(@RequestParam(“username“) String username
@RequestParam(“password“) String password
@RequestParam(“newpassword“) String newpassword ModelMap model) {
if (!userServices.isUserExist(username)) {
model.addAttribute(“msg“ “用户名不存在!“);
} else {
if (password.equals(userServices.getPasswordByUsername(username))) {
userServices.modifyPasswordByUsername(username newpassword);
model.addAttribute(“msg“ “修改密码成功!“);
} else {
model.addAttribute(“msg“ “密码错误!“);
}
}
return “index“;
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        841  2017-11-17 22:11  SSM\.classpath

     文件       1036  2017-11-17 22:11  SSM\.project

     文件        503  2017-11-17 22:11  SSM\.settings\.jsdtscope

     文件        364  2017-11-17 22:11  SSM\.settings\org.eclipse.jdt.core.prefs

     文件        461  2017-11-17 22:11  SSM\.settings\org.eclipse.wst.common.component

     文件        345  2017-11-17 22:11  SSM\.settings\org.eclipse.wst.common.project.facet.core.xml

     文件         49  2017-11-17 22:11  SSM\.settings\org.eclipse.wst.jsdt.ui.superType.container

     文件          6  2017-11-17 22:11  SSM\.settings\org.eclipse.wst.jsdt.ui.superType.name

     文件       2612  2017-11-18 12:29  SSM\build\classes\test\actions\WebAction.class

     文件        338  2017-11-18 12:28  SSM\build\classes\test\dao\UserDao.class

     文件        964  2017-11-18 11:58  SSM\build\classes\test\entity\User.class

     文件        997  2017-11-18 12:24  SSM\build\classes\test\mapper\User.xml

     文件       1507  2017-11-18 12:30  SSM\build\classes\test\services\UserServices.class

     文件       2239  2017-11-18 12:29  SSM\src\test\actions\WebAction.java

     文件        283  2017-11-18 12:28  SSM\src\test\dao\UserDao.java

     文件        509  2017-11-18 11:58  SSM\src\test\entity\User.java

     文件        997  2017-11-18 12:24  SSM\src\test\mapper\User.xml

     文件       1009  2017-11-18 12:30  SSM\src\test\services\UserServices.java

     文件         39  2017-11-17 22:11  SSM\WebContent\meta-INF\MANIFEST.MF

     文件       1145  2017-11-18 11:55  SSM\WebContent\views\index.jsp

     文件       1534  2017-11-18 23:14  SSM\WebContent\WEB-INF\applicationContext.xml

     文件        428  2017-11-17 22:23  SSM\WebContent\WEB-INF\configuration.xml

     文件      61829  2014-07-05 20:11  SSM\WebContent\WEB-INF\lib\commons-logging-1.2.jar

     文件     712734  2014-04-06 21:54  SSM\WebContent\WEB-INF\lib\mybatis-3.2.7.jar

     文件      53312  2017-11-16 16:14  SSM\WebContent\WEB-INF\lib\mybatis-spring-1.3.1.jar

     文件     999635  2017-08-29 04:13  SSM\WebContent\WEB-INF\lib\mysql-connector-java-5.1.44-bin.jar

     文件     339104  2016-12-21 17:44  SSM\WebContent\WEB-INF\lib\spring-aop-3.2.18.RELEASE.jar

     文件      51441  2016-12-21 17:46  SSM\WebContent\WEB-INF\lib\spring-aspects-3.2.18.RELEASE.jar

     文件     614434  2016-12-21 17:44  SSM\WebContent\WEB-INF\lib\spring-beans-3.2.18.RELEASE.jar

     文件     868229  2016-12-21 17:44  SSM\WebContent\WEB-INF\lib\spring-context-3.2.18.RELEASE.jar

............此处省略42个文件信息

评论

共有 条评论