简体   繁体   中英

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. 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. Specifically, with the default context path of "/", tags like <spring:url value="/foo/bar"/> end up getting rendered as //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.

I can think of two workarounds:

  • Specify --context-path "" argument to webapp-runner - this seems "best" since it corresponds to the 7.0.27.1 behavior
  • Write the tags as <spring:url context="" .../> - unsure what additional consequences there might be, considering how SpringUrl uses leading slash to determine 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 "" . 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 .

I had tried with both <spring:url> and ${pageContext.request.contextPath} . Upgrading webapp-runner solved the problem in both cases.

More details: http://bit.ly/1zuL1T1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM