日期:2014-05-18  浏览次数:20637 次

使用 tomcat,如何把网站的缺省路径设置到自己的web应用上
比如,我在tomcat/webapps下面建立了自己的web应用test. 在 tomcat/conf/catalina/localhos里面建了test.xml,内容如下
<Context path="" docBase="test"
  privileged="true" antiResourceLocking="false" antiJARLocking="false">

  <!-- Link to the user database we will get roles from 
  <ResourceLink name="users" global="UserDatabase"
  type="org.apache.catalina.UserDatabase"/>-->

</Context>

我想通过 http://localhost:8080这样的url来访问test的web应用,但页面返回404错误。 只能通过http://localhost:8080/test访问。我该怎么配置呢?

------解决方案--------------------
<Context path="/test" docBase="docBase里是你工程路径"
privileged="true" antiResourceLocking="false" antiJARLocking="false"> 

<!-- Link to the user database we will get roles from 
<ResourceLink name="users" global="UserDatabase" 
type="org.apache.catalina.UserDatabase"/>--> 

</Context> 

------解决方案--------------------
哦,这个 路径 本来 就是tomcat 早就 hardcode 进去的,,我想到一个办法,到 tomcat 自带的 ROOT下面,
找到index.jsp 不把里面内容清空,,,
写上 你的项目路径 这样写完全可以 ;
<%
response.sendRedirect("你的项目路径");
%>
当你访问http://localhost:8080/ 这个就自动跳到你的项目地方了 。。我就是这样做的。