我正在做角度和弹簧靴的工作。
我的工作请求适用于HTTP GET
s,
但我遇到POST
请求控制器返回null
这是有效的:
@RequestMapping(value="/foo.do", method=RequestMethod.GET)
@ResponseBody
public ModelAndView indexStringGet(Model model, @RequestParam(id) String orderId,
HttpServletRequest request){
System.out.println("=== get Index");//
System.out.println("=== orderId" + orderId);
String path = request.getContextPath();
System.out.println("== path" + path);
ModelAndView mv = new ModelAndView();
mv.setViewName("test1");
return mv;
}
但不支持此Request方法'POST'
@RequestMapping(value="/foo.do", method=RequestMethod.POST)
@ResponseBody
public ModelAndView indexStringPost(Model model, @RequestParam(id) String orderId,
HttpServletRequest request){
System.out.println("=== get Index");//
System.out.println("=== orderId" + orderId);
String path = request.getContextPath();
System.out.println("== path" + path);
ModelAndView mv = new ModelAndView();
mv.setViewName("test1");
return mv;
}
这是结果:
"status": 405,
"error": "Method Not Allowed",
"exception": "org.springframework.web.HttpRequestMethodNotSupportedException",
"message": "Request method 'POST' not supported",
"path": "/SpringBoot/test1"
由于