servlet上下文到tomcat 7 root [英] servlet context to tomcat 7 root
问题描述
将servlet上下文置于 tomcat 7
root的最佳方法是什么?我在这里试过这篇文章但对我不起作用;我正在使用 Apache Tomcat / 7.0.42
。
Whats the best approach to place servlet context to tomcat 7
root? I have tried this post here but didn't work for me; i'm using Apache Tomcat/7.0.42
.
PS:我不想重命名项目名称为 ROOT.war
。
P.S: I don't want to rename the project name as ROOT.war
.
我已经按照其中一个答案中的说明放置了 context
标记,但仍然以root身份获取 tomcat
主页:
I have placed the context
tag as explained in one of the answers, but still getting the tomcat
home page as root:
<Host name="localhost" appBase="webapps"
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="app-renderer" path="/" reloadable="true" />
</Host>
更新2
问题是关于 webapps
中的 ROOT
目录,现在删除后我可以将该应用程序设为root。
Update 2
the problem was about the ROOT
directory in webapps
, after removing now I could have the app as root.
推荐答案
在Tomcat的 conf / server.xml
文件中,您通常会有一个条目
In your Tomcat's conf/server.xml
file, you'll typically have an entry
<Context docBase="yourApp" path="/somePath" reloadable="true" source="someSource"/>
适用于您的申请。
更改路径 /
<Context docBase="yourApp" path="/" reloadable="true" source="someSource"/>
在主机
条目中添加此项。例如
Add this in the Host
entry. For example
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="yourApp" path="/" reloadable="true" />
</Host>
其中 docBase
属性是您的应用程序显示在 webapps
文件夹中。 文档解释了每个属性的含义。
where the docBase
attribute is the name of your app as it appears in the webapps
folder. The docs explain the meaning of each attribute.
这篇关于servlet上下文到tomcat 7 root的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!