[英]Spring @RequestMapping on controller
I'm using Spring MVC 3.1.3. 我正在使用Spring MVC 3.1.3。
I'd like to do the same as the example shown in the documentation . 我想和文档中显示的示例一样。
@RequestMapping
on the controller and a 'root' method. @RequestMapping
控制器和'root'方法。
But Spring does not handle correctly. 但Spring无法正确处理。
Here's my code : 这是我的代码:
@Controller
@RequestMapping("/test")
public class TestController {
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public String list() {
return "test";
}
}
When I try http://localhost/test-project/test
I get a 404 Not Found but it's working when I use http://localhost/test-project/test/
. 当我尝试
http://localhost/test-project/test
我得到404 Not Found但是当我使用http://localhost/test-project/test/
时它正在工作。
Does anyone know how I can fix this ? 有谁知道我怎么解决这个问题?
Thanks, 谢谢,
Smoky 烟
EDIT: 编辑:
Here's the log : 这是日志:
16:13:36,085 | DEBUG | RequestMappingHandlerMapping:209 | Looking up handler method for path /test
16:13:36,087 | DEBUG | RequestMappingHandlerMapping:219 | Did not find handler method for [/test]
Change the method requestMapping tag on the method to... 将方法上的requestMapping标记更改为...
@RequestMapping(value = {"", "/", "/list"}, method = RequestMethod.GET)
Edit addition from comment : 从评论中编辑添加:
Have you tried setting the controller to @RequestMapping("/test*")
您是否尝试将控制器设置为
@RequestMapping("/test*")
在Controller级别@RequestMapping
使用通配符:
@RequestMapping("/test*")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.