拥有tomcat应用程序的最佳方法位于/ [英] Best way to have tomcat app reside at /

查看:71
本文介绍了拥有tomcat应用程序的最佳方法位于/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在工作中,我们在一台tomcat服务器上运行许多Spring应用程序.有些应用程序具有自己的域,并在apache中带有虚拟主机,该主机将/url的请求重写为/context_root/url.

At work we have many Spring apps running on one tomcat server. Some of the apps have their own domains with a virtualhost in apache that rewrites requests from /url to /context_root/url.

这一切都很好,除了我使用一些处理url的springs标签库时,其他都很好.一个示例是<form:form>标记,该标记创建/context_root/form的操作并使用户离开/.现在,即使发生这种情况,该应用程序仍然可以运行,但是管理人员不想看到上下文根.

This is all fine and good except for when I use some of springs tag libs that handle urls. An example is the <form:form> tag which creates an action of /context_root/form and takes the user away from /. Now, the app still works when that happens but management doesn't want to see the context root.

解决此问题的最佳方法是什么?

What is the best way to tackle this?

推荐答案

万一有人偶然发现了这个问题,我最终找到了答案.

In case anyone stumbles into this, I did end up finding the answer.

使用Tomcat,您可以拥有多个主机.因此,我将应用程序设置为默认Web应用程序的主机.这是一个示例:

With Tomcat you can have multiple hosts. So I setup a host with my app as the default webapp. Here's an example:

将另一台主机添加到server.xml

Add another Host to server.xml

<Host name="lilhug.mydomain.com"  appBase="lilhug"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false"/>

创建一些文件和目录

mkdir $CATALINA_HOME/lilhug
mkdir $CATALINA_HOME/conf/Catalina/lilhug.mydomain.com

如果要为此主机使用Tomcat管理器

If you want the Tomcat manager for this host

cd $CATALINA_HOME/conf/Catalina
cp localhost/manager.xml lilhug.mydomain.com

然后重新启动tomcat,您就很好.使用在新主机上运行的/manager将lilhug应用程序部署到/或将war复制到$CATALINA_HOME/lilhug/ROOT.war

Then restart tomcat and you're good. Deploy the lilhug app to / using the /manager running at your new host or copy the war to $CATALINA_HOME/lilhug/ROOT.war

这篇关于拥有tomcat应用程序的最佳方法位于/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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