我正在尝试在spring boot应用程序中映射注销URL。我指定的每个其他映射都工作得很好但是这个logout url映射拒绝映射到控制器
这是带有提交命令的表单
<form method="post" action="/livechat/logout">
<input type="submit" value="Leave Chat"/>
</form>
当您点击提交按钮时,这是控制器
@RequestMapping(value = "/logout", method = RequestMethod.POST)
public ModelAndView logout(HttpServletRequest request,
HttpServletResponse response) {
for (Cookie cookie : request.getCookies()) {
if ("name".equals(cookie.getName()) || "email".equals(cookie.getName())) {
// clear cookie
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}
return new ModelAndView("redirect:/");
}
在我的application.properties文件中我有服务器URL定义的配置
server.context-path= /livechat
#server port
server.port = 8081
当我点击退出时,我收到此错误
Fri Aug 05 11:56:22 WAT 2016
There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'POST' not supported
当我看到url borwser时,它似乎是正确的,但我得到了错误回复
http://localhost:8081/livechat/logout
请出错。 Kiindly协助!