package com.clear.controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.clear.entity.User;
import com.clear.service.UserService;
@Controller
@RequestMapping("user")
public class UserController {
@Resource
private UserService userService;
@RequestMapping("getAllUser")
public String getAllUser(HttpServletRequest request) {
request.setAttribute("userList", userService.getAllUser());
return "index";
}
@RequestMapping(value = "/getUser/{id}")
public String getUser(@PathVariable Long id, HttpServletRequest request) {
request.setAttribute("user", userService.getUser(id));
return "/editUser";
}
@RequestMapping("/toAddUser")
public String toAddUser() {
System.out.println("UserController.toAddUser()");
return "/addUser";
}
@RequestMapping("/addUser")
public String addUser(User user, HttpServletRequest request) {
userService.addUser(user);
return "redirect:/user/getAllUser";
}
//@RequestMapping("/delUser")
@RequestMapping(value = "/delUser/{id}")
public void delUser(@PathVariable String id, HttpServletResponse response) {
String result = "{\"result\":\"error\"}";
if (userService.delUser(id)) {
result = "{\"result\":\"success\"}";
}
response.setContentType("application/json");
try {
PrintWriter out = response.getWriter();
out.write(result);
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("/updateUser")
public String updateUser(User user, HttpServletRequest request) {
if (userService.updateUser(user)) {
// user = userService.getUser(user.getId());
// request.setAttribute("user", user);
return "redirect:/user/getAllUser";
} else {
return "/error";
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
最新SSH(springmvc4.0+spring4.0+hibernate4.3.4)全注解整合增删改查示例 C3PO数据库连接池,代理事务 初来乍到,不到位的地方还请大家多给给宝贵的意见,不明白的地方随时Q我 21990226,错误的地方狠狠指出 供稿---坐看云起的从容
资源推荐
资源详情
资源评论
收起资源包目录
sshthink.rar (73个子文件)
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
src
com
config
jdbc.properties 100B
springmvc-servlet.xml 4KB
hibernate.cfg.xml 957B
clear
dao
UserDao.java 303B
impl
UserDaoImpl.java 2KB
controller
UserController.java 2KB
service
UserService.java 314B
impl
UserServiceImpl.java 726B
entity
User.java 940B
junit
TestBean.java 60B
.project 1KB
WebRoot
images
aop1.png 19KB
addUser.jsp 880B
META-INF
MANIFEST.MF 36B
WEB-INF
web.xml 2KB
classes
com
config
jdbc.properties 100B
springmvc-servlet.xml 4KB
hibernate.cfg.xml 957B
clear
dao
UserDao.class 418B
impl
UserDaoImpl.class 2KB
controller
UserController.class 3KB
service
UserService.class 430B
impl
UserServiceImpl.class 1KB
entity
User.class 1KB
junit
TestBean.class 281B
lib
hibernate-jpa-2.1-api-1.0.0.Final.jar 111KB
spring-webmvc-portlet-4.0.0.RELEASE.jar 171KB
spring-jms-4.0.0.RELEASE.jar 206KB
spring-beans-4.0.0.RELEASE.jar 654KB
dom4j-1.6.1.jar 307KB
spring-instrument-tomcat-4.0.0.RELEASE.jar 10KB
spring-core-4.0.0.RELEASE.jar 933KB
hibernate-commons-annotations-4.0.4.Final.jar 74KB
spring-messaging-4.0.0.RELEASE.jar 223KB
antlr-2.7.7.jar 435KB
spring-jdbc-4.0.0.RELEASE.jar 410KB
mchange-commons-java-0.2.3.4.jar 568KB
spring-context-4.0.0.RELEASE.jar 928KB
hibernate-c3p0-4.3.4.Final.jar 39KB
spring-test-4.0.0.RELEASE.jar 431KB
spring-webmvc-4.0.0.RELEASE.jar 645KB
spring-websocket-4.0.0.RELEASE.jar 246KB
spring-aop-4.0.0.RELEASE.jar 343KB
jboss-logging-annotations-1.2.0.Beta1.jar 11KB
jandex-1.1.0.Final.jar 75KB
jboss-logging-3.1.3.GA.jar 56KB
mysql-connector-java-5.0.8-bin.jar 528KB
javassist-3.18.1-GA.jar 697KB
commons-logging.jar 59KB
aspectjweaver.jar 1.47MB
spring-expression-4.0.0.RELEASE.jar 202KB
spring-oxm-4.0.0.RELEASE.jar 77KB
spring-context-support-4.0.0.RELEASE.jar 131KB
c3p0-0.9.2.1.jar 414KB
aopalliance.jar 4KB
spring-instrument-4.0.0.RELEASE.jar 7KB
jboss-transaction-api_1.2_spec-1.0.0.Final.jar 27KB
spring-orm-4.0.0.RELEASE.jar 309KB
spring-framework-bom-4.0.0.RELEASE.jar 6KB
hibernate-core-4.3.4.Final.jar 4.98MB
spring-aspects-4.0.0.RELEASE.jar 50KB
spring-tx-4.0.0.RELEASE.jar 242KB
spring-web-4.0.0.RELEASE.jar 646KB
spring-build-src-4.0.0.RELEASE.jar 71KB
editUser.jsp 770B
js
jquery-1.7.1.min.js 92KB
index.jsp 1KB
test.jsp 851B
.mymetadata 297B
.classpath 4KB
.myeclipse
共 73 条
- 1
bxqybxqy
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页