在DispatcherServlet中找不到带有URI [/ BMS / $%7B]的HTTP请求的映射,名称为“spring”

时间:2014-07-07 10:53:04

标签: java spring spring-mvc thymeleaf

我正在开展一个春季项目,我发现这个奇怪的错误,找不到404

当我调用localhost时:8080 / BMS /我收到以下错误

 No mapping found for HTTP request with URI [/BMS/$%7B] in DispatcherServlet with name 'spring'

请注意:我将一个Index.html文件作为webapp文件夹下的欢迎文件重定向到WEB-INF文件夹中的登录页面

所以我的问题是错误中的$%7B是什么以及我如何解决这个问题?

的index.html

<head>
   <meta http-equiv="refresh" content="0; url=http://localhost:8080/BMS/login.html" />
</head>

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>BMS</display-name>

   <filter>
        <filter-name>encoding-filter</filter-name>
        <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encoding-filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

  <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>
          org.apache.catalina.servlets.DefaultServlet
        </servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
   <servlet>
   <servlet-name>spring</servlet-name>
   <servlet-class>
    org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
     <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/*</url-pattern>
       </servlet-mapping> 
   <servlet-mapping>
     <servlet-name>spring</servlet-name>
    <url-pattern>/login.html</url-pattern>
    </servlet-mapping> 
    <servlet-mapping>
     <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
    </servlet-mapping> 

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

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

</web-app>

1 个答案:

答案 0 :(得分:0)

根据网址编码,参考%7B表示{

查看index.html的这一行

<meta http-equiv="refresh" content="0; url=http://localhost:8080/BMS/login.html" />

尝试在零&amp;之间删除空格网址。 将网址设为网址

<meta http-equiv="refresh" content="0;URL=http://localhost:8080/BMS/login.html" />

希望这会对你有所帮助。