SpringBoot @RestController,找到了不明确的映射
发布时间:2020-12-15 01:26:18 所属栏目:大数据 来源:网络整理
导读:嗨,我的Sample中有一个简单的RestController: @RestControllerpublic class PersonController { @RequestMapping(name = "/getName",method = GET) public String getName() { return "MyName"; } @RequestMapping(name = "/getNumber",method = GET) publi
嗨,我的Sample中有一个简单的RestController:
我有SampleController用于启动SpringBoot:
当我尝试运行SampleCotroller时,会发生以下异常:
问题出在哪里?一个RestController中不能有更多的RequestMappings? 非常感谢您的回复 最佳答案
您必须使用value属性来定义映射.您现在使用了名称,它只为映射提供了一个名称,但根本没有定义任何映射.所以目前你的方法都是未映射的(在这种情况下,两者都映射到相同的路径).将方法更改为:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |