最近在忙着一个练习,前端的参数传到后台都变为null
百度了下,发现最终是因为用错一个注解导致,使用路径直接访问是通过@PathVariabl String id,看了一下使用注解获取路径中传递参数 ,共有以下几种情况:
@RequestMapping(value = "/{id}/{str}") 方法中是使用 @PathVariabl String id这种形式的注解 |
@RequestMapping(method = RequestMethod.POST) public String processSubmit(@ModelAttribute("pojo") Pojo pojo) |
@RequestMapping(method = RequestMethod.GET) public get(HttpServletRequest request, HttpServletResponse response) { System.out.println(request.getParameter("a")); } |
@RequestMapping(value = "/requestParam", method = RequestMethod.GET) public String setupForm(@RequestParam("a") String a, ModelMap model) |