My Spring MVC application is runnning on a Tomcat behind an Apache 2 ac开发者_StackOverflow社区ting as a proxy. I access my app directly in tomcat via an url like http://localhost:8080/myapp
. I access my app via proxy with an url like http://localhost/tomcat/myapp
.
The second url makes my app behave incorrectly, because it supposes it lives in /myapp
context path, but via the proxy it should live in /tomcat/myapp
.
Is there a variable in Spring or Servlet API, that holds /tomcat/myapp
if I am accessing it via the proxy, and /myapp
if I am accessing it directly?
Thanx
I think you need to enable proxy support then. This link might help you or give a little hint in this regards.
- http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html
Just stumbled upon this post while searching for the config setting for tomcat. There is a much easier way to configure tomcat to handle the exact situation you are experiencing. See:
http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html
Simple configure a connector for the proxy in tomcat, and the servlet/struts context path issues will resolve.
-edit: Obviously I didn't read #2 comment...
I mean when I redirect to "/index.jsp" it actually redirects to "http://localhost/myapp/index.jsp" instead of "http://localhost/tomcat/myapp/index.jsp"
Redirect to index.jsp
instead of /index.jsp
When you redirect to /index.jsp this acts as an absolute url and it gets redirected to myapp/index.jsp
. index.jsp
is a relative url and will redirect to tomcat/myapp/index.jsp
精彩评论