web.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/smtt-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>smtt</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>smtt</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/default.htm</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/404.htm</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/500.htm</location>
</error-page>
</web-app>
其中default.htm,404.htm,500.htm在smtt-servlet.xml影射处理如下:
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/default.htm">defaultPageController</prop>
<prop key="/404.htm">error404Controller</prop>
<prop key="/500.htm">error500Controller</prop>
</props>
</property>
</bean>
现象:
在smtt部署成功后,输入URL:http://localhost:8080/smtt/并不会自动进入default.htm,发生404(500)错误也不会转到404.htm(500.htm).但这些地址都是有效的,都可以请求到正确数据的.
问题:
这是怎么回事?如何解决?
------解决方法--------------------------------------------------------
<welcome-file-list>
<welcome-file>default.htm</welcome-file>
</welcome-file-list>
------解决方法--------------------------------------------------------
web.xml中的只能是实际存在的html或jsp文件。