警告:org.springframework.web.servlet.PageNotFound-请求方法'GET'不支持


问题内容

启动服务器时出现此异常: 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";
    }

}

我真的不知道问题出在哪里,因为我是春天的新手,甚至无法弄清楚问题出在哪里。

有人可以指导我解决这个问题吗


问题答案:

尝试这个

更改

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

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

(在上一篇文章中,我注意到您具有login-page = login)