springMVC问题集锦

一、405 request method post not supported

产生原因:在一个方法单元里面,方法声明POST请求:

@RequestMapping(value="/login", method=RequestMethod.POST)

登录成功之后发起GET请求:

response.sendRedirect("http://www.aaa.com/index.html");

造成间歇性405异常。

解决方式:

1、GET请求跳转移到view视图里做;

2、使用RedirectView(当然可以配置一些参数)

ModelAndView mv = new ModelAndView();
mv.setView(RedirectView(redirectURL));
return mv;


你可能感兴趣的:(springMVC问题集锦)