我在 Eclipse 中创建了动态 Web 项目,WEB-INF 文件夹中有index.html。我点击项目主文件夹 Run as > Run on server 选择 Tomcat v7.0,完成,运行正常。但是,当我将 index.html 重命名为另一个名称时,我收到消息:
请求的资源 (/MyProject/) 不可用。
- 如何更改默认页面?
- 我可以放入默认页面 asp 文件吗?
我的 web.xml 是:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>MyFirstServlet</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description>new</description>
<display-name>GrettingServlet</display-name>
<servlet-name>GrettingServlet</servlet-name>
<servlet-class>GrettingServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GrettingServlet</servlet-name>
<url-pattern>/GrettingServlet</url-pattern>
</servlet-mapping>
</web-app>
在 web.xml 中(在 TOMCAT_HOME/webapps/you_application 下),您有以下内容:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>/axis2-web/index.jsp</welcome-file>
</welcome-file-list>
更改为您的新文件名
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)