【发布时间】:2017-02-08 22:01:06
【问题描述】:
我有以下 web.xml:
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/mvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
当我转到localhost:port/myapplication/someincorrecturl 时,它会正确地将我重定向到 index.html 文件。但是当我转到localhost:port/myapplication/someincorrecturl1/someincorrecturl2 时,应用程序给了我一个 404 错误。如何解决包含多个路径的任何错误 URL 的问题?
【问题讨论】:
-
我也有同样的问题,请问您是怎么解决的
标签: java spring http-status-code-404 web.xml