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";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Spring+SpringMVC+Mybatis最简单的整合示例
共47个文件
jar:23个
xml:7个
java:4个
1星 需积分: 11 56 下载量 68 浏览量
2017-11-18
23:29:19
上传
评论 4
收藏 6.94MB RAR 举报
温馨提示
Spring+SpringMVC+Mybatis最简单的整合示例,希望对大家有所帮助。
资源推荐
资源详情
资源评论
收起资源包目录
SSM.rar (47个子文件)
SSM
.project 1KB
WebContent
WEB-INF
configuration.xml 428B
applicationContext.xml 1KB
lib
spring-oxm-3.2.18.RELEASE.jar 75KB
spring-aop-3.2.18.RELEASE.jar 331KB
spring-struts-3.2.18.RELEASE.jar 35KB
spring-jms-3.2.18.RELEASE.jar 201KB
spring-tx-3.2.18.RELEASE.jar 237KB
spring-orm-3.2.18.RELEASE.jar 376KB
spring-webmvc-portlet-3.2.18.RELEASE.jar 184KB
spring-instrument-tomcat-3.2.18.RELEASE.jar 10KB
spring-webmvc-3.2.18.RELEASE.jar 630KB
spring-beans-3.2.18.RELEASE.jar 600KB
spring-expression-3.2.18.RELEASE.jar 192KB
spring-context-3.2.18.RELEASE.jar 848KB
mybatis-spring-1.3.1.jar 52KB
spring-test-3.2.18.RELEASE.jar 448KB
spring-core-3.2.18.RELEASE.jar 865KB
spring-web-3.2.18.RELEASE.jar 617KB
spring-instrument-3.2.18.RELEASE.jar 7KB
mysql-connector-java-5.1.44-bin.jar 976KB
spring-context-support-3.2.18.RELEASE.jar 126KB
spring-jdbc-3.2.18.RELEASE.jar 397KB
spring-aspects-3.2.18.RELEASE.jar 50KB
commons-logging-1.2.jar 60KB
mybatis-3.2.7.jar 696KB
SpringMVC-servlet.xml 1KB
web.xml 1KB
views
index.jsp 1KB
META-INF
MANIFEST.MF 39B
src
test
services
UserServices.java 1009B
mapper
User.xml 997B
dao
UserDao.java 283B
actions
WebAction.java 2KB
entity
User.java 509B
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 461B
.jsdtscope 503B
build
classes
test
services
UserServices.class 1KB
mapper
User.xml 997B
dao
UserDao.class 338B
actions
WebAction.class 3KB
entity
User.class 964B
.classpath 841B
共 47 条
- 1
资源评论
- qq_338249522018-12-13不能用,运行都是错误
- Zhang_YiDa2017-12-06骗人的,文件打不开
yongh701
- 粉丝: 2101
- 资源: 38
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功