Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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
Java Spring MVC:HTTP状态404,在名为'的DispatcherServlet中找不到URI为[/BugzillaReport/]的HTTP请求的映射;spring dispatcher';_Java_Spring_Spring Mvc_Http Status Code 404_Web.xml - Fatal编程技术网

Java Spring MVC:HTTP状态404,在名为'的DispatcherServlet中找不到URI为[/BugzillaReport/]的HTTP请求的映射;spring dispatcher';

Java Spring MVC:HTTP状态404,在名为'的DispatcherServlet中找不到URI为[/BugzillaReport/]的HTTP请求的映射;spring dispatcher';,java,spring,spring-mvc,http-status-code-404,web.xml,Java,Spring,Spring Mvc,Http Status Code 404,Web.xml,我正在努力提出我的申请。但我得到的HTTP状态是404,控制台警告为“警告:在名为“spring dispatcher”的DispatcherServlet中找不到URI为[/BugzillaReport/]的HTTP请求的映射” 我检查了很多人的答案,但仍然无法解决这个问题。请伸出你的手 关于应用程序:上传一个xml,在后端创建另一个xml,并为用户提供下载新xml的选项。(但申请尚未完成) 以下是我所有文件的内容: web.xml <?xml version="1.0" encodin

我正在努力提出我的申请。但我得到的HTTP状态是404,控制台警告为“警告:在名为“spring dispatcher”的DispatcherServlet中找不到URI为[/BugzillaReport/]的HTTP请求的映射”

我检查了很多人的答案,但仍然无法解决这个问题。请伸出你的手

关于应用程序:上传一个xml,在后端创建另一个xml,并为用户提供下载新xml的选项。(但申请尚未完成)

以下是我所有文件的内容:

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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>BugzillaReport</display-name>
  <servlet>
        <servlet-name>spring-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>spring-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>
index.jsp

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<!DOCTYPE html>
<html>
 <head>
 <title>Image File Upload</title>
 </head>
 <body>
<h1>File Upload Example - JavaTpoint</h1>

<h3 style="color:red">${filesuccess}</h3>
<form:form method="post" action="savefile" enctype="multipart/form-data">
<p><label for="image">Choose Image</label></p>
<p><input name="file" id="fileToUpload" type="file" /></p>
<p><input type="submit" value="Upload"></p>
</form:form>
</body>
</html>

图像文件上传
文件上传示例-JavaTpoint
${filesuccess}
选择图像


尝试添加到web.xml
contextConfigLocation
ContextLoaderListener

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd" id="WebApp_ID" version="3.0">
   <display-name>BugzillaReport</display-name>
   <servlet>
      <servlet-name>spring-dispatcher</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>spring-dispatcher</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>
   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
   </context-param>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>
</web-app>

BugzillaReport
春季调度员
org.springframework.web.servlet.DispatcherServlet
1.
春季调度员
/
上下文配置位置
/WEB-INF/dispatcher-servlet.xml
org.springframework.web.context.ContextLoaderListener

我认为问题在于servlet与URI的映射。您已将所有内容映射到
/
,而它应该映射到
/BugzillaReport

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd" id="WebApp_ID" version="3.0">
   <display-name>BugzillaReport</display-name>
   <servlet>
      <servlet-name>spring-dispatcher</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>spring-dispatcher</servlet-name>
      <url-pattern>/BugzillaReport</url-pattern>
   </servlet-mapping>
   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
   </context-param>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>
</web-app>

BugzillaReport
春季调度员
org.springframework.web.servlet.DispatcherServlet
1.
春季调度员
/BugzillaReport
上下文配置位置
/WEB-INF/dispatcher-servlet.xml
org.springframework.web.context.ContextLoaderListener

我添加了以下几行:contextConfigLocation/WEB-INF/spring-dispatcher-servlet.xml org.springframework.WEB.context.ContextLoaderListener在给出url时仍然显示“在名为“spring dispatcher”的DispatcherServlet中找不到URI为[/BugzillaReport/]的HTTP请求的映射”
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd" id="WebApp_ID" version="3.0">
   <display-name>BugzillaReport</display-name>
   <servlet>
      <servlet-name>spring-dispatcher</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>spring-dispatcher</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>
   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
   </context-param>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd" id="WebApp_ID" version="3.0">
   <display-name>BugzillaReport</display-name>
   <servlet>
      <servlet-name>spring-dispatcher</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>spring-dispatcher</servlet-name>
      <url-pattern>/BugzillaReport</url-pattern>
   </servlet-mapping>
   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
   </context-param>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>
</web-app>