[英]Spring @RequestMapping on controller
我正在使用Spring MVC 3.1.3。
我想和文檔中顯示的示例一樣。 @RequestMapping
控制器和'root'方法。
但Spring無法正確處理。
這是我的代碼:
@Controller
@RequestMapping("/test")
public class TestController {
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public String list() {
return "test";
}
}
當我嘗試http://localhost/test-project/test
我得到404 Not Found但是當我使用http://localhost/test-project/test/
時它正在工作。
有誰知道我怎么解決這個問題?
謝謝,
煙
編輯:
這是日志:
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]
將方法上的requestMapping標記更改為...
@RequestMapping(value = {"", "/", "/list"}, method = RequestMethod.GET)
從評論中編輯添加:
您是否嘗試將控制器設置為@RequestMapping("/test*")
在Controller級別@RequestMapping
使用通配符:
@RequestMapping("/test*")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.