启动服务器时出现此异常:
HTTP Status 405 - Request method 'GET' not supported
我的控制器是:
@Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
@RequestMapping(value = "/", method = RequestMethod.POST)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
return "login";
}
}
我真的不知道是什么问题,因为我是一个非常新的春天,甚至无法弄清楚问题是什么。
有人可以指导我修复这个
答案 0 :(得分:3)
RequestMapping错误。
@RequestMapping(value =“/”,method = RequestMethod.POST
)
它只需要POST请求并返回405 StatusCode任何请求而不是POST。
所以,应该是
@RequestMapping(value =“/”,method = RequestMethod.GET
)
答案 1 :(得分:2)
试试这个
更改
@RequestMapping(value = "/", method = RequestMethod.POST)
到
@RequestMapping(value = "/login", method = RequestMethod.GET)
(在您之前的帖子中,我注意到您有login-page = login)
答案 2 :(得分:1)
更改
@RequestMapping(value = "/", method = RequestMethod.POST)
到
@RequestMapping(value = "/login", method = RequestMethod.GET)