简体   繁体   English

更改tomcat 6中的默认应用程序

[英]change default application in tomcat 6

I got an maven project that produces a war package. 我有一个产生战争包裹的Maven项目。 When I copy war to tomcat 6 webapps directory and start tomcat, I see my application is being deployed and running but when I try to go localhost I got default tomcat page displayed. 当我将war复制到tomcat 6 webapps目录并启动tomcat时,我看到我的应用程序正在部署并正在运行,但是当我尝试进入localhost时,会显示默认的tomcat页面。 From googling around I got that I have to define context.xml file in my META-INF folder but I have no idea how can I define it. 通过谷歌搜索,我不得不在META-INF文件夹中定义context.xml文件,但是我不知道如何定义它。 Can someone give me an example? 有人可以给我一个例子吗?

Thanks 谢谢

最简单的方法是将您的webapp文件夹重命名为ROOT

i think what you want is when type in browser http://localhost:8080 you are directed towards your application welcome page 我认为您想要的是在浏览器http://localhost:8080您将转到您的应用程序欢迎页面

It is quite easy to override that page. 覆盖该页面非常容易。 Inside $TOMCAT_HOME/conf/web.xml there is a section called and it looks like this: 在$ TOMCAT_HOME / conf / web.xml中有一个名为的部分,看起来像这样:

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

The default servlet attempts to load the index.* files in the order listed. 缺省servlet尝试按列出的顺序加载index。*文件。 You may easily override the index.jsp file by creating an index.html file at $TOMCAT_HOME/webapps/ROOT. 您可以通过在$ TOMCAT_HOME / webapps / ROOT上创建index.html文件来轻松覆盖index.jsp文件。 It's somewhat common for that file to contain a new static home page or a redirect to a servlet's main page. 该文件包含一个新的静态主页或重定向到Servlet主页的情况在某种程度上很常见。 A redirect would look like: 重定向看起来像:

 <html>

<head>
<meta http-equiv="refresh" content="0;URL=http://mydomain.com/some/path/to/servlet/homepage/">
</head>

<body>
</body>

</html>

If you simply want to access you application with not the intention i explained above 如果您只是想访问您的应用程序而不是上面我解释过的意图

http:/localhost:PortNumber//WelcomePage.html http:// localhost:PortNumber // WelcomePage.html

Create a file called context.xml in your webapp/META-INF folder. 在webapp / META-INF文件夹中创建一个名为context.xml的文件。 With this content 有了这个内容

<Context path="/yourAppName" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM