public class UserController {
@RequestMapping(value="/save8")
@ResponseBody
public void save8(String[] strs) {
System.out.println(Arrays.asList(strs));
}
@RequestMapping(value="/save7")
@ResponseBody
public void save7(User user) {
System.out.println(user);
}
@RequestMapping(value="/save6")
@ResponseBody
public void save6(String username,int age) {
System.out.println(username);
System.out.println(age);
}
@RequestMapping(value="/save5")
public String save5(HttpServletRequest httpServletRequest) {
httpServletRequest.setAttribute("username","请来在的话");
return "success";
}
@RequestMapping(value="/save4")
public String save4(Model model) {
model.addAttribute("username","我来自何方nima");
return "success";
}
@RequestMapping(value="/save3")
public String save3(ModelAndView modelAndView) {
modelAndView.addObject("username","请来在的话");
return "success";
}
@RequestMapping(value="/save2")
public ModelAndView save2() {
ModelAndView modelAndView=new ModelAndView();
modelAndView.addObject("username","我来自何方");
modelAndView.setViewName("success");
return modelAndView;
}
@RequestMapping(value="/save",method = {RequestMethod.GET},params = {"username"})
public String save() {
System.out.println("controller创建了");
return "success";
}
}
|
|