无法更改netbeans的默认起始页



我在Netbeans中创建了一个名为test9的web应用程序。我在其中创建了各种jsp文件和servlet等。现在我想将起始页index.html更改为index.jsp,所以我创建了一个新文件index.jsp并删除了index.html,但在运行它之后,它仍然试图打开index.html并显示404错误资源未找到,我甚至在我的xml文件中进行了更改,但仍然在这样做。我还需要做一些其他的修改吗?

xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
    <filter-name>RequestLoggingFilter</filter-name>
    <filter-class>bean.RequestLoggingFilter</filter-class>
</filter>
<filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>bean.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>AuthenticationFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>RequestLoggingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>bean.LoginServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>LogoutServlet</servlet-name>
    <servlet-class>bean.LogoutServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>DepartmentServlet</servlet-name>
    <servlet-class>bean.DepartmentServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>C_userServlet</servlet-name>
    <servlet-class>bean.C_userServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>statusServlet</servlet-name>
    <servlet-class>bean.statusServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>FileServlet</servlet-name>
    <servlet-class>bean.FileServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>SearchServlet</servlet-name>
    <servlet-class>bean.SearchServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>NoCacheFilter</servlet-name>
    <servlet-class>bean.NoCacheFilter</servlet-class>
</servlet>
<servlet>
    <servlet-name>forgotServlet</servlet-name>
    <servlet-class>bean.forgotServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>passServlet</servlet-name>
    <servlet-class>bean.passServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>LogoutServlet</servlet-name>
    <url-pattern>/LogoutServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>DepartmentServlet</servlet-name>
    <url-pattern>/DepartmentServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>C_userServlet</servlet-name>
    <url-pattern>/C_userServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>statusServlet</servlet-name>
    <url-pattern>/statusServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>FileServlet</servlet-name>
    <url-pattern>/FileServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>SearchServlet</servlet-name>
    <url-pattern>/SearchServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>NoCacheFilter</servlet-name>
    <url-pattern>/NoCacheFilter</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>forgotServlet</servlet-name>
    <url-pattern>/forgotServlet</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
</web-app>

在netBeans中,您可以右键单击项目,然后单击属性。将打开一个新的弹出窗口,在左侧菜单上将有一个标签调用run。点击这里,然后在"相对URL"中输入

/nameOfYourJspFile.jsp

和它工作,但我仍然不知道为什么

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

我知道这是一个旧的帖子,但是因为我有同样的问题并解决了它,所以我发布我的答案来帮助一些可能陷入这种情况的人。

对我来说有效的是将新的jsp文件从WEB-INF文件夹中取出。

相关内容

  • 没有找到相关文章

最新更新