0

如何处理除资源映射文件夹之外的所有 URL 请求?

在这个例子中,我处理了所有路径(这就是我想要的),但现在我无法访问资源文件夹,即使我 ​<resources mapping="/resources/**" location="/resources/" />在里面设置dispatcher-servlet.xml

@RequestMapping(method=RequestMethod.GET)
public String iallURL(HttpServletRequest request, Writer writer) {
    //read all paths
    return "some";
}

有没有办法解决这个问题?

4

1 回答 1

2

目前,我只能建议您将您@RequestMapping的值更改为/.

@RequestMapping(value = "/", method=RequestMethod.GET)
public String iallURL(HttpServletRequest request, Writer writer) {
    //read all paths
    return "some";
}

另一种解决方案是为资源处理程序设置顺序。

<resources order="-1" mapping="/resources/**" location="/resources/" />

order值为负数,因为RequestMappingHandlerMapping控制器方法的实例默认为0。首先评估最小的顺序。

于 2013-09-22T00:28:23.537 回答