Tomcat通过server.xml映射上下文 [英] Tomcat mapping context via server.xml

查看:93
本文介绍了Tomcat通过server.xml映射上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个战争并将其部署到我的$ CATALINA_HOME / webapps文件夹就好了。然后我想测试配置它以指向任意位置的战争,例如c:\ tmp \ mywar.war。这是我在$ CATALINA_HOME / conf中的server.xml文件中放入的内容。

I created a war and deployed it to my $CATALINA_HOME/webapps folder just fine. Then I wanted to test configuring it to point to a war at an arbitrary location such as c:\tmp\mywar.war. Here is what I put in the server.xml file within $CATALINA_HOME/conf.

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="/blah" docBase="h:/tmp/mywar.war" reloadable="true" />
</Host>

当我尝试加载localhost:8080 / blah时,Tomcat返回404。如果我将docBase指向爆炸战争,它就可以正常运行。我在这里缺少什么?

Tomcat returns 404 when I try to load localhost:8080/blah. If I point docBase to the exploded war instead, it works just fine. What am I missing here?

推荐答案

如果你想在 http://上找到一个网站myhost:8080 / myTestContext ,将以下内容放入 $ Catalina_home $ / conf / localhost / whateveryoulike.xml

If you want to have a site available at http://myhost:8080/myTestContext, put the following in $Catalina_home$/conf/localhost/whateveryoulike.xml

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <Context deployOnStartup="true" docBase="C:\path\to\your\docBase\" path="/myTestContext" reloadable="false">
    <Manager pathname=""/>
</Context>

这篇关于Tomcat通过server.xml映射上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆