package com.jie.controller;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.omg.CORBA.Request;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.jie.entity.User;
import com.jie.service.IUserService;
@Controller
public class UserController {
@Resource
private IUserService UserService;
@RequestMapping("toAdd")
public String toAddPager(){
return "add";
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String addUser(@RequestParam String name,@RequestParam String password) {
User user= new User();
user.setName(name);
user.setPassword(password);
UserService.save(user);
return "redirect:/findAll.do";
}
@RequestMapping(value="/delete" )
public String deleteUser(@RequestParam("Id") int Id){
UserService.delete(Id);
return "redirect:/findAll.do";
}
@RequestMapping(value="/edit")
public String edit(@RequestParam int id,Model model){
User user=UserService.findById(id);
model.addAttribute(user);
return "edit";
}
@RequestMapping(value="/update")
public String updateUser(@ModelAttribute User user){
UserService.merge(user);
return "redirect:/findAll.do";
}
@RequestMapping(value="/findById")
public String findOneUser(@RequestParam("Id")int Id,Map<String,User> map ){
map.put("user",UserService.findById(Id));
try{
map.get("user").getPassword();
return "single";
}catch (NullPointerException e) {
return "error";
}
}
@RequestMapping(value="/findAll")
public String findAllUser(Model model){
List<User> Users=UserService.findAll();
model.addAttribute("Users",Users);
return "List";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
springMvc+Mybatis+maven整合
共53个文件
jar:17个
xml:9个
jsp:6个
需积分: 6 7 下载量 100 浏览量
2013-12-25
19:28:29
上传
评论
收藏 16.15MB ZIP 举报
温馨提示
springMvc+spring+Mybatis+maven整合, 基础的增删改查
资源推荐
资源详情
资源评论
收起资源包目录
MyBatis.zip (53个子文件)
MyBatis
.project 1KB
user.sql 1KB
.mymetadata 294B
src
spring-servlet.xml 1KB
applicationContext.xml 3KB
com
jie
service
UserServiceImpl.java 1KB
IUserService.java 290B
controller
UserController.java 2KB
mapper
UserMapper.xml 1KB
dao
UserMapper.java 395B
entity
User.java 614B
datasource.properties 130B
target
war
work
webapp-cache.xml 1KB
MyBatis-0.0.1-SNAPSHOT.war 8.06MB
test-classes
WebRoot
WEB-INF
jsp
error.jsp 823B
single.jsp 857B
add.jsp 1010B
edit.jsp 1KB
List.jsp 1KB
classes
spring-servlet.xml 1KB
applicationContext.xml 3KB
com
jie
service
IUserService.class 397B
UserServiceImpl.class 2KB
controller
UserController.class 4KB
mapper
UserMapper.xml 1KB
dao
UserMapper.class 456B
entity
User.class 1KB
datasource.properties 130B
lib
mybatis-3.2.3.jar 697KB
spring-context-4.0.0.RELEASE.jar 928KB
mysql-connector-java-5.1.27.jar 852KB
spring-expression-4.0.0.RELEASE.jar 202KB
servlet-api-3.0-alpha-1.jar 170KB
mybatis-spring-1.2.1.jar 48KB
spring-tx-4.0.0.RELEASE.jar 242KB
spring-webmvc-4.0.0.RELEASE.jar 645KB
spring-web-4.0.0.RELEASE.jar 646KB
spring-aop-4.0.0.RELEASE.jar 343KB
aspectjweaver-1.7.4.jar 1.76MB
spring-beans-4.0.0.RELEASE.jar 654KB
commons-logging-1.1.1.jar 59KB
spring-core-4.0.0.RELEASE.jar 933KB
spring-jdbc-4.0.0.RELEASE.jar 410KB
aopalliance-1.0.jar 4KB
mybatis-generator-core-1.3.1.jar 470KB
spring-mvc-3.0.xsd 9KB
web.xml 2KB
index.jsp 955B
META-INF
MANIFEST.MF 36B
.myeclipse
.settings
org.maven.ide.eclipse.prefs 271B
org.eclipse.jdt.core.prefs 396B
pom.xml 3KB
.classpath 439B
共 53 条
- 1
资源评论
o6875461
- 粉丝: 0
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功