升级前一切正常。我已经升级到Spring框架5.3并更新了配置文件。 访问 contextRoot(index.html) 或任何其他请求时,我在日志中收到 FileNotFoundException。
web.xml
<servlet>
<servlet-name>abcd</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>abcd</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
配置.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd">
<context:component-scan base-package="xxx.aaa.abcd.controller,xxx.aaa.abcd.bean,xxx.aaa.abcd.bean.command,xxx.aaa.abcd.validator" />
<context:annotation-config />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
<mvc:default-servlet-handler/>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/report.xls"><ref bean="viewStatReportController" /></entry>
</map>
</property>
<property name="interceptors">
<list>
<ref bean="securityInterceptor"/>
</list>
</property>
<property name="mappings">
<props>
<prop key="index.html">homeController</prop>
</props>
</property>
</bean>
当尝试访问 localhost:9080/abcd 时 - 它重定向到 localhost:9080/abcd/index.html 这是正确的,但它不断记录以下异常
javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /index.html
at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service(DefaultExtensionProcessor.java:1604)
at org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler.handleRequest(DefaultServletHttpRequestHandler.java:122)
at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
我是否保留
<prop key="index.html">homeController</prop>
或删除它。结果是一样的。
删除了
<mvc:default-servlet-handler/>
并且成功了。