如何在 Tomcat 中为虚拟主机设置 webapp 特定参数?
我想在 Tomcat 中进行此设置:
- 虚拟主机
- webapp 直接驻留在 ROOT 中并且自动部署
- 我需要在 Tomcat 配置中传递一些特定的 webapp 参数(战争之外)
首先我有这种情况:
<Host name="my.domain.com" appBase="vhosts/my.domain.com" unpackWARs="true" autoDeploy="true">
</Host>
和 ROOT.war 在目录
$CATALINA_BASE/vhosts/my.domain.com/
->一切正常
第二现在我尝试添加上下文参数
<Host name="my.domain.com" appBase="vhosts/my.domain.com" unpackWARs="true" autoDeploy="true">
<Context docBase="/" reloadable="true">
<Parameter name="serverRole" value="dev" override="true"/>
</Context>
</Host>
- > my.domain.com
无法再访问应用程序 (404)
->我还尝试将上下文从主机移动到位于 $CATALINA_BASE/conf/Catalina/my.domain.com/
中的单独的 ROOT.xml
文件,但没有成功
实际上我不知道要为路径或 docBase 设置什么,但似乎我迷路了。
I would like to have this setup in Tomcat:
- virtual host
- webapp resides directly in ROOT and is autoDeployed
- I need to pass some specific webapp parameter in Tomcat configuration (outside war)
1st I have this scenario:
<Host name="my.domain.com" appBase="vhosts/my.domain.com" unpackWARs="true" autoDeploy="true">
</Host>
and ROOT.war
in directory $CATALINA_BASE/vhosts/my.domain.com/
-> everything works fine
2nd now I try to add the context parameter
<Host name="my.domain.com" appBase="vhosts/my.domain.com" unpackWARs="true" autoDeploy="true">
<Context docBase="/" reloadable="true">
<Parameter name="serverRole" value="dev" override="true"/>
</Context>
</Host>
-> app is no more accessible by my.domain.com
(404)
-> I also tried to move the Context from Host to separate ROOT.xml
file residing in $CATALINA_BASE/conf/Catalina/my.domain.com/
but with no success
Actually I don't know what to set for path or docBase
, but it seems that I am lost.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后我找到了解决方案。
最后一句话,
我一开始没有想到删除 docBase 属性的原因是我认为它是强制性属性,因为它在 Tomcat 的文档中被标记为粗体。
乔克
Finally I found the solution.
Final words,
the thing why it didn't come to my mind to remove the docBase attribute at the beginning was that I thought that it was mandatory attribute as it is marked bold in the Tomcat's documentation.
JoeK