Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse抛出错误-“;文件名引用到";main.html“;这在web内容中不存在”;web.xml的404错误_Eclipse_Spring Mvc_Struts_Http Status Code 404_Web.xml - Fatal编程技术网

Eclipse抛出错误-“;文件名引用到";main.html“;这在web内容中不存在”;web.xml的404错误

Eclipse抛出错误-“;文件名引用到";main.html“;这在web内容中不存在”;web.xml的404错误,eclipse,spring-mvc,struts,http-status-code-404,web.xml,Eclipse,Spring Mvc,Struts,Http Status Code 404,Web.xml,我在Eclipse中运行简单web项目时遇到了一个问题 我将首先演示创建项目的步骤:- 1) 新的Spring模板项目。 2) 选择Spring MVC项目。 3) 单击“完成”。 4) 现在,我在“src”下的“webapps”文件夹中创建了一个新文件名“login.html” 5) 现在我尝试在web.xml中添加欢迎文件标记 6) 当我这样做时,我从Eclipse的web.xml中得到了上述警告。 7) 如果我运行该应用程序,会出现404错误 这是我的web.xml <?xml ve

我在Eclipse中运行简单web项目时遇到了一个问题

我将首先演示创建项目的步骤:-

1) 新的Spring模板项目。
2) 选择Spring MVC项目。
3) 单击“完成”。
4) 现在,我在“src”下的“webapps”文件夹中创建了一个新文件名“login.html”
5) 现在我尝试在web.xml中添加欢迎文件标记
6) 当我这样做时,我从Eclipse的web.xml中得到了上述警告。
7) 如果我运行该应用程序,会出现404错误

这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Processes application requests -->
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>login.html</welcome-file>
</welcome-file-list>

上下文配置位置
/WEB-INF/spring/root-context.xml
org.springframework.web.context.ContextLoaderListener
appServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/spring/appServlet/servlet-context.xml
1.
appServlet
/
login.html

这是我的登录名。html

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Hello
</body>
</html>

在此处插入标题
你好
请帮我解决这个问题,我不知道到底是什么错误。

提前感谢。

如果希望欢迎文件正常工作,请尝试更改servlet映射,如下所示:

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/something/</url-pattern>
</servlet-mapping>

appServlet
/某物/
目前,所有请求都将发送到Spring的DispatcherServlet,并查找“/”的请求映射。在这种情况下,需要一个控制器来处理“/”请求,该请求将返回login.html作为视图。你可以找一个快速入门的例子