Java spring启动后modelandview错误
我正在做angularjs和spring boot的工作 我的工作请求适用于Java spring启动后modelandview错误,java,spring,spring-mvc,http-post,spring-boot,Java,Spring,Spring Mvc,Http Post,Spring Boot,我正在做angularjs和spring boot的工作 我的工作请求适用于httpgets, 但是我遇到了POST请求控制器返回null 这是有效的: @RequestMapping(value="/foo.do", method=RequestMethod.GET) @ResponseBody public ModelAndView indexStringGet(Model model, @RequestParam(id) String orderId, HttpServle
httpget
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;
}
但不支持此请求方法“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"
谢谢为什么要将
模型和视图作为@ResponseBody
返回?你的帖子的URL是/foodo
我想应该是/foo.do
。。。