今天定义了2个相同value 但不同method的路径 然后华丽丽的报错了
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'testController' method to {[POST, GET] /test/login11}: There is already 'testController' bean method
然后看提示信息是路径冲突了,提示我已经有get/post方法了,然后我一脸蒙蔽,我明明定义的是一个get 一个post呀
@RequestMapping(value = "login", method = RequestMethod.GET)
public String login(Model model) {
}
@RequestMapping(value = "login", method = RequestMethod.POST)
public String loginUser(Model model, String userName, String password, HttpSession session, RedirectAttributes redirectAttributes) {}
然后一番排查 发现是自己傻逼了 自己在最上面的定义了method = {RequestMethod.POST, RequestMethod.GET}
@Controller @Api(description = "专门用于测试的Controller") @RequestMapping(value = "/test/", method = {RequestMethod.POST, RequestMethod.GET}) public class TestController {
所以 年轻人 还是要细心点的好