什么是将servlet上下文放置到tomcat 7 root的最佳方法? 我在这里试过这篇文章,但对我不起作用; 我正在使用Apache Tomcat/7.0.42 。
PS:我不想将项目名称重命名为ROOT.war 。
更新
我已经按照其中一个答案中的说明放置了context标记,但仍然以root身份获取tomcat主页:
<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用户。
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.
P.S: I don't want to rename the project name as ROOT.war.
Update
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>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文件中,您通常会有一个条目
<Context docBase="yourApp" path="/somePath" reloadable="true" source="someSource"/>为您的应用程序。
将路径更改为/
<Context docBase="yourApp" path="/" reloadable="true" source="someSource"/>在Host条目中添加它。 例如
<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文件夹中。 文档解释了每个属性的含义。
In your Tomcat's conf/server.xml file, you'll typically have an entry
<Context docBase="yourApp" path="/somePath" reloadable="true" source="someSource"/>for your application.
Change the path to /
<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>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.
更多推荐
发布评论