RegisterController.java
package org.travelzen.hotel.user.controller;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.travelzen.hotel.user.service.IUserService;
import org.travelzen.hotel.user.vo.User;
@Controller
//@RequestMapping("/travelzen/hotel/user")
public class RegisterController {
private IUserService userService;
public IUserService getUserService() {
return userService;
}
@Resource
public void setUserService(IUserService userService) {
this.userService = userService;
}
@RequestMapping(value="/register", method=RequestMethod.GET)
public String register(Model model) {
model.addAttribute(new User());//user
return "travelzen/hotel/user/register";
}
@RequestMapping(value="/register", method=RequestMethod.POST)
public String register(User user) {
//List<User> users = userService.getAllUser();
//users.add(user);
userService.Add(user);
//return "redirect:travelzen/hotel/user/list";
return InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/travelzen/hotel/users";
}
}
上一篇: 家庭冷幽默这恐怕最搞笑了
下一篇: linux环境源码搭建Apache服务