接收请求参数及数据回显
接收请求参数及数据回显 接收一个参数 //http://localhost:8080/r/user/t1?username=julia @GetMapping("/user/t1") public String test1(@RequestParam("username") String name, Model model) { return "test"; } 接受一个对象 //http://localhost:8080/r/user/t2?id=11&name=julia&age=16 //前端传递的参数名必须和对象的字段名一致 @GetMapping("/user/t2") public String test2(User user){ return "test"; } 通过ModelAndView回显 public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { ModelAndView mv = new ModelAndView(); String result = "hellospringmvc"; mv.addObject("msg", result); mv