欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

RegisterController.java  

程序员文章站 2022-07-03 23:00:46
...

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";

}

 

}