java Tomcat 从 URL 中删除上下文路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15251484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat removing context path from URL
提问by Sachin
I can only access my application when I give context path like:
当我提供如下上下文路径时,我只能访问我的应用程序:
www.mydomain.com/projName
and not with:
而不是:
www.mydomain.com
If I give www.mydomain.com
, it loads tomcat application under ROOT. What change do I have to make to be able to access application without context path?
如果我给www.mydomain.com
,它会在 ROOT 下加载 tomcat 应用程序。我必须做哪些更改才能在没有上下文路径的情况下访问应用程序?
回答by Avinash Singh
You can change the below in your {CATALINA_HOME}/conf/server.xml
to point to your webapp,
您可以更改以下内容{CATALINA_HOME}/conf/server.xml
以指向您的 web 应用程序,
<Context path="" docBase="your application folder relative
path from webapps" debug="0">
</Context>
回答by Héctor Luaces Novo
You should provide the contents of your configuration files, specially your context.xml located in /META-INF/context.xml.
您应该提供配置文件的内容,特别是位于 /META-INF/context.xml 中的 context.xml。
In that file, did you try to specify the context path to ""?
在该文件中,您是否尝试将上下文路径指定为“”?
Something like:
就像是:
<Context path=""/>
<Context path=""/>
Don't forget to redeploy your solution after any change to context.xml.
不要忘记在对 context.xml 进行任何更改后重新部署您的解决方案。