黑马程序员技术交流社区
标题:
spring_mvc
[打印本页]
作者:
血染江山
时间:
2019-6-5 18:06
标题:
spring_mvc
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";
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2