spring报错org.springframework.web.servlet.DispatcherServlet noHandlerFound
web.xml配置:
<servlet>
<servlet-name>vsitest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>vsitest</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
vsitest-servlet.xml配置:
<!-- 配置url映射 -->
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/listUser.htm">listUserController</prop>
<prop key="/validLogin.htm">listUserController</prop>
</props>
</property>
</bean>
<!-- ================================================================ -->
<bean id="listUserController"
class="com.wadata.VSITest.Controller.ListUserController">
<!-- 方法名解析器,根据传过来的url值解析成对应的urlmapping对应的controller的方法 -->
<property name="methodNameResolver">
<bean
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/listUser.htm">listUser</prop>
<prop key="/validLogin.htm">checkLogin</prop>
</props>
</property>
</bean>
</property>
<property name="userService" ref="userService" />
</bean>
页面通过url /listUser.htm 一直报错
2011-11-16 16:05:54 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping for [/hy2/views/listUser.htm] in DispatcherServlet with name 'vsitest'
------解决方案--------------------
<prop key="*/listUser.htm">listUserController</prop>
改成这样试试
------解决方案--------------------
<bean
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="*/listUser.htm">listUser</prop>
<prop key="*/validLogin.htm">checkLogin</prop>
</props>
</property>
<property name="pathMatcher">
<bean class="org.springframework.util.AntPathMatcher"/>
</property>
</bean>