日期:2014-05-17 浏览次数:20682 次
@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(@ModelAttribute("user") @Valid User user,@RequestParam(value = "nameSearch", required = false) String nameSearch){
if(user.getId() != null && !user.getId().equals("")){
User userTemp = userService.get(user.getId());
userTemp.setName(user.getName());
userTemp.setPassword(user.getPassword());
userTemp.setEmail(user.getEmail());
userService.saveOrUpdate(userTemp);
}else{
userService.saveOrUpdate(user);
}
return "redirect:/user?nameSearch=" + nameSearch;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView list(@RequestParam(value = "pageNo", required = false) Integer pageNo,@RequestParam(value = "nameSearch", required = false) String nameSearch){
ModelAndView view = new ModelAndView();
pageNo = pageNo==null?1:pageNo;
nameSearch = nameSearch==null?"":nameSearch;
Page page = userService.queryUserPageByCriteria(pageNo, 10, nameSearch);
view.addObject("page", page);
view.addObject("nameSearch",nameSearch);
view.setViewName("user/index");
return view;
}