我正在尝试将 WebJars-Locator 与 Spring-Boot 应用程序一起使用来映射 JAR 资源。根据他们的网站,我创建了一个这样的 RequestMapping:
@ResponseBody
@RequestMapping(method = RequestMethod.GET, value = "/webjars-locator/{webjar}/{partialPath:.+}")
public ResponseEntity<ClassPathResource> locateWebjarAsset(@PathVariable String webjar, @PathVariable String partialPath)
{
问题在于 partialPath 变量应该包含第三个斜杠之后的任何内容。然而,它最终会限制映射本身。此 URI 映射正确:
http://localhost/webjars-locator/angular-bootstrap-datetimepicker/datetimepicker.js
但是这个根本没有映射到处理程序,只是返回一个 404:
http://localhost/webjars-locator/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css
根本区别只是路径中应由正则表达式(“.+”)处理但当该部分有斜杠时似乎不起作用的组件数量。
如果它有帮助,这将在日志中提供:
2015-03-03 23:03:53.588 信息 15324 --- [main] swsmmaRequestMappingHandlerMapping:映射“{[/webjars-locator/{webjar}/{partialPath:.+}],methods=[GET],params=[ ],headers=[],consumes=[],produces=[],custom=[]}" 到公共 org.springframework.http.ResponseEntity app.controllers.WebJarsLocatorController.locateWebjarAsset(java.lang.String,java.lang.字符串)2
Spring-Boot 中是否有某种类型的隐藏设置可以在 RequestMappings 上启用正则表达式模式匹配?