Java eclipse动态web项目-默认起始页
我是在Eclipse动态web项目中创建的,在web-INF文件夹中有index.html。我单击项目的主文件夹runas>runonserver选择了tomcatv7.0,finish,它运行正常。但是,当我将index.html重命名为另一个名称时,会收到以下消息: 请求的资源(/MyProject/)不可用Java eclipse动态web项目-默认起始页,java,eclipse,jsp,project,Java,Eclipse,Jsp,Project,我是在Eclipse动态web项目中创建的,在web-INF文件夹中有index.html。我单击项目的主文件夹runas>runonserver选择了tomcatv7.0,finish,它运行正常。但是,当我将index.html重命名为另一个名称时,会收到以下消息: 请求的资源(/MyProject/)不可用 如何更改默认页面 我可以放入默认页面asp文件吗 我的web.xml是: MyFirstServlet index.html index.htm index.jsp default.
MyFirstServlet
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
新的
GrettingServlet
GrettingServlet
GrettingServlet
GrettingServlet
/GrettingServlet
需要检查的东西很少
1) Servlet mapping extension in web.xml
2) Welcome file definition in web.xml
确保更改时有扩展名和名称
web.xml
将位于web-INF
文件夹中。在web.xml中(在TOMCAT\u HOME/webapps/you\u应用程序下),您有:
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
/axis2 web/index.jsp
更改为新文件名(1)如何更改默认页面
=>更改web.xml中的欢迎文件列表。更改为所需的文件名,无论使用哪个文件名
2) 我可以放入默认页面asp文件吗
=>您可以将扩展更改为asp,但您需要web.xml中的servlet映射。但是,如果您谈论的是MicrosoftASP页面
,我认为您无法根据我的知识添加它们,因为(jsp和ASP)都使用不同的技术
编辑:
<?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>/greetings.asp</url-pattern>
</servlet-mapping>
</web-app>
MyFirstServlet
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
新的
GrettingServlet
GrettingServlet
GrettingServlet
GrettingServlet
/问候语.asp
在这里,您将使用url
http://localhost:8080/myapp/greetings.asp
当出现404错误时也会发生这种情况,Tomcat默认搜索索引文件。jsp/html,您必须从web.xml文件中的Tomcat文件夹更改它。在Tomcat Eclipse内部或安装的文件夹系统(c/files Program/apache…)中
打开Eclipse->单击服务器->在本地主机配置中选择Tomcat v9.0服务器-/strong>选择“web.xml”->滚动到底部或查找“->”filename.xml”
我没有web.xml文件。。如果我使用Tomcat 7,我可以在哪里找到他?web.xml将在您的项目-->web-INF文件夹中。如果没有,那么您需要创建一个并添加欢迎文件定义。如果index.html没有找到它,请转到下一个,依此类推?您能解释一下我必须在servlet映射中编写什么吗?我编辑了我的帖子并添加了web.xml。@NandkumarTekale很抱歉给您写了一条评论。我确信如果我写了一个问题,那么它就会被关闭。我已经用servlet和JSP开发了一个项目,但现在我对启动应用程序运行什么感到困惑。从某种意义上说,如果我运行JSP,那么当我运行servlet Everything runs时,应该来自servlet的数据不会再次加载,但是JSP中很少有javascript函数没有被调用。现在我的困惑是启动应用程序应该运行什么,我应该将JSP作为默认页面运行,还是将servlet作为默认页面运行,以及建议的方法。请您指导