开发者

Spring MVC: "No mapping for [...] in DispatcherServlet with name 'dispatcher'"

Can someone help me. In Spring MVC I'm getting the error

  • WARNING: No mapping for [/TechBooks/details.htm] in DispatcherServlet with name 'dispatcher'

1) First of all, in web.xml, I use the standard DispatcherServlet which intercepts all *.htm, nothing unusual here, this was pre-written for me:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>

2) In dispatcher-servlet.xml, I am using the SimpleUrlHandlerMapping, again this is standard and pre-written:

<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="index.htm">indexControlle开发者_如何学Gor</prop>
        </props>
    </property>
</bean>

3) Also in dispatcher-servlet.xml, I define my FormController class called "DetailsFormController", that maps to details.htm:

<bean name="/details.htm" class="techbooks.web.DetailsFormController"/>

4) And the class DetailsFormController is a FormController for a form.

package techbooks.web;

public class DetailsFormController extends SimpleFormController {
    ....
    }

When I execute the resource /details.htm, however, I get the above error.

  • WARNING: No mapping for [/TechBooks/details.htm] in DispatcherServlet with name 'dispatcher'

Any ideas would be appreciated. Thanks.


Can you change your bean difinition to

     <bean name="/TechBooks/details. htm"  class="techbooks.web.DetailsFormController"/>

Or write a urlmapping handler for TechBooks


I found out what the issue was.

When using the SimpleUrlHandlerMapping, the Controller name has to be DetailsController, not DetailsFormController, so it maps automatically to the right JSP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜