[英]Context path conflict with Spring UrlTag in webapp-runner?
We have a Java/Spring app deployed into Heroku, using the excellent webapp-runner
as the Tomcat-lite servlet container.我们有一个 Java/Spring 应用程序部署到 Heroku,使用优秀的webapp-runner
作为 Tomcat-lite servlet 容器。 In upgrading from 7.0.27.1 to 7.0.31.1, it seems the behavior for setting a default context path of "/" causes problems with <spring:url>
tags.在从 7.0.27.1 升级到 7.0.31.1 时,设置“/”的默认上下文路径的行为似乎会导致<spring:url>
标签出现问题。 Specifically, with the default context path of "/", tags like <spring:url value="/foo/bar"/>
end up getting rendered as //foo/bar
.具体来说,使用“/”的默认上下文路径,像<spring:url value="/foo/bar"/>
这样的标签最终会被渲染为//foo/bar
。 All browsers I tested on OS X (Chrome, Safari, Firefox), for example, don't seem to handle those particularly gracefully, and try to load http://foo/bar
, resulting in all kinds of chaos.例如,我在 OS X 上测试的所有浏览器(Chrome、Safari、Firefox)似乎都没有特别优雅地处理这些,并尝试加载http://foo/bar
,导致各种混乱。
I can think of two workarounds:我可以想到两种解决方法:
--context-path ""
argument to webapp-runner
- this seems "best" since it corresponds to the 7.0.27.1 behavior为webapp-runner
指定--context-path ""
参数 - 这看起来是“最好的”,因为它对应于 7.0.27.1 行为<spring:url context="" .../>
- unsure what additional consequences there might be, considering how SpringUrl
uses leading slash to determine UrlType
.将标签编写为<spring:url context="" .../>
- 考虑SpringUrl
如何使用前导斜杠来确定UrlType
,不确定可能会产生什么额外的后果。Are either of these reasonable?这两者是否合理? If not, is there some other solution I should consider?如果没有,我应该考虑其他一些解决方案吗?
webapp-runner-7.0.34.1 has changed the default --context-path
back to ""
. webapp-runner-7.0.34.1 已将默认的--context-path
回""
。 If you upgrade, it should fix your issue.如果您升级,它应该可以解决您的问题。
I had similar issue of double slash // and upgrading from webapp-runner 7.0.34.0 to webapp-runner 7.0.34.1 solved the problem for me .我有类似的双斜杠问题//从 webapp-runner 7.0.34.0 升级到webapp-runner 7.0.34.1 为我解决了这个问题。
I had tried with both <spring:url>
and ${pageContext.request.contextPath}
.我已经尝试过<spring:url>
和${pageContext.request.contextPath}
。 Upgrading webapp-runner solved the problem in both cases.升级 webapp-runner 解决了这两种情况下的问题。
More details: http://bit.ly/1zuL1T1更多详情: http : //bit.ly/1zuL1T1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.