我有一个现有的mvc应用程序,但是当我添加
时工作正常<bean class="org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration"></bean>
启用spring-data-rest,然后通过
提供静态资源<mvc:resources mapping="/resources/**" location="/resources/" />
无法访问。 实际上我在请求静态资源时会在日志中得到这个
2013-06-06 15:33:21,035 DEBUG DispatcherServlet.doService(823) - DispatcherServlet with name 'eips-databus' processing GET request for [/eips-databus/scripts/easyUI/themes/gray/easyui_custom.css]
2013-06-06 15:33:21,035 DEBUG RequestMappingHandlerMapping.getHandlerInternal(226) - Looking up handler method for path /scripts/easyUI/themes/gray/easyui_custom.css
2013-06-06 15:33:21,035 DEBUG ExceptionHandlerExceptionResolver.resolveException(132) - Resolving exception from handler [null]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
有什么建议吗? 提前致谢
答案 0 :(得分:0)
我面临着一些不同之处。在我的例子中,我添加了静态资源的处理程序:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("/WEB-INF/static/");
}
之后,一些具有长路径的静态文件(如/a/b/c/d.css
或/a/b/c/d.js
)充当静态内容,但某些文件(如/a/b/c.js
)不是。
我发现在我的情况下RepositoryRestHandlerMapping
使用Ordered.HIGHEST_PRECEDENCE
注册自己,并且大多数CSS和JavaScript请求都通过[/{repository}/{id}/{property}]
等规则处理到此处理程序中。
This is a bug in Spring-Data,现在已修复(感谢Oliver Gierke),您可以从snapshot repo获得固定版本2.0.0.BUILD-SNAPSHOT,我希望这可以提供帮助。