使用用SpringMVC,我有一个捕获所有REST请求的方法:如何在Spring MVC中定义请求映射的优先级?
@RequestMapping(value = "/**")
public Object catchAll(@RequestBody(required = false) Object body, HttpMethod method, HttpServletRequest request, HttpServletResponse response) {
// ...
}
现在我想赶上刚刚与以下端点几个要求:
@RequestMapping(value = "/test", method = RequestMethod.POST)
public Object post(@RequestBody Object body, HttpMethod method, HttpServletRequest request, HttpServletResponse response) {
// ...
}
现在,当我打电话:
/测试
第二种方法永远不会被调用。
我能做些什么来让我的第二个方法总是被调用来代替第一个方法?
你不应该有抓到什么所有请求都像方法1. – Asura