Results 1 to 7 of 7

Thread: No mapping found for HTTP request with URI

  1. #1
    Join Date
    Aug 2008
    Posts
    4

    Default No mapping found for HTTP request with URI

    Hi! I am newable in SPRING, and have the following question:
    I am trying to use MultiActionController for MVC implementation.I decided to delegate the request from the
    JSP file to some class I wrote (i.e there is NO inheritance from MultiActionController).

    I am getting the error:
    No mapping found for HTTP request with URI [/SpringMVC/index.dispatch] in DispatcherServlet with name 'dispatcher'

    I added log prints and I see that my requests do not handled by MultiActionController at all!


    my web.xml has the next lines:

    Code:
    ...
    <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
     
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>*.dispatch</url-pattern>
        </servlet-mapping>
    ....
    dispatcher-servlet.xml is as follows:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="..."
     xmlns:xsi="..."
     xsi:schemaLocation="...">
      <bean id="propsResolver"
       class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
       
       <property name="mappings">
              <value>
               /index.dispatch=goToNextForm
               /*.dispatch=goToNextForm
              </value>
       </property>
      </bean>
      
      <bean id="paramMultiController"
       class="org.springframework.web.servlet.mvc.multiaction.MultiActionController">
       <property name="methodNameResolver" ref="propsResolver"/>
       <property name="delegate">
        <bean class="controller.Form1Controller" />
       </property>
      </bean>
      
     <!-- MULTI CONTROLLER END -->
      
     </beans>
    my JSP has the next target on submit:

    Code:
    <form action="index.dispatch">
    ...
    </form>
    The question i what do I do wrong????? why the request does not handled by MultiActionController?
    Last edited by rotbart; Aug 18th, 2008 at 01:22 AM. Reason: remove extra information

  2. #2
    Join Date
    Aug 2008
    Posts
    4

    Default

    No even single reply... to bad
    OK
    I would like to ask another question:

    What do I need to do to cause all requests to be handled by MultiActionController?
    Do I need to change web.xml mapping and to add MultiactionController instead of DispatcherServlet?

    Thanks in advance.

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    I suggest you read the reference guide and take a look at the sample applications. First understand how things work. The DispatcherServlet handles ALL the request but DELEGATES to a controller. In your case your MAC.

    The question i what do I do wrong????? why the request does not handled by MultiActionController?
    There is no Controller named 'goToNextPage' at least not in the snippet you showed here.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4

    Default

    Hi

    The DispatcherServlet routes the control to the specified controller/handler. The DispatcherServlet looks for the handler-mapping specified in the context. By default it uses BeanNameURLHandlerMapping.


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="..."
    xmlns:xsi="..."
    xsi:schemaLocation="...">
    <bean id="propsResolver"
    class="org.springframework.web.servlet.mvc.multiac tion.PropertiesMethodNameResolver">

    <property name="mappings">
    <value>
    /index.dispatch=goToNextForm
    /*.dispatch=goToNextForm
    </value>
    </property>
    </bean>

    <bean name="/index.dispatch"
    class="org.springframework.web.servlet.mvc.multiac tion.MultiActionController">
    <property name="methodNameResolver" ref="propsResolver"/>
    <property name="delegate">
    <bean class="controller.Form1Controller" />
    </property>
    </bean>

    <!-- MULTI CONTROLLER END -->

    </beans>
    Plz note the way i have defined the bean for MultiActionContoller, i have specifed a name instead of an id. Here i am making use of the BeanNameURLHandlerMapping

    U can also use SimpleURLHandlerMapping if not BeanNameURLHandlerMapping

    U can look into the documentation for indepth understanding.
    Let me know if it works

  5. #5
    Join Date
    Aug 2008
    Posts
    4

    Default

    Quote Originally Posted by Marten Deinum View Post
    I suggest you read the reference guide and take a look at the sample applications. First understand how things work. The DispatcherServlet handles ALL the request but DELEGATES to a controller. In your case your MAC.


    There is no Controller named 'goToNextPage' at least not in the snippet you showed here.
    Marten , thanks for your reply!
    'goToNextPage' is method name that handles the request.
    And yes , I read the rererences, more than once.

  6. #6
    Join Date
    Aug 2008
    Posts
    4

    Default

    Quote Originally Posted by Madhusudhan81 View Post
    Hi

    The DispatcherServlet routes the control to the specified controller/handler. The DispatcherServlet looks for the handler-mapping specified in the context. By default it uses BeanNameURLHandlerMapping.




    Plz note the way i have defined the bean for MultiActionContoller, i have specifed a name instead of an id. Here i am making use of the BeanNameURLHandlerMapping

    U can also use SimpleURLHandlerMapping if not BeanNameURLHandlerMapping

    U can look into the documentation for indepth understanding.
    Let me know if it works

    Madhusudhan81 , Thanks for your reply!

    Yes, it solves the problem: if I add URL path in "name" attribute of the bean, it works.

    I found another similar solution. If I add BeanNameURLHandlerMapping and order him to delegate
    the requst handling to my MultiActionController bean, it works also:

    Code:
    <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    			<props>
    				<prop key="/*">paramMultiController</prop>
    			</props>
    		</property>
    	</bean>
    As I understand, my problem was that Spring did not forwarded request to MultiActionController bean. It is
    strange: I saw examples in Spring docummentation, there are NO additional mappings
    (like SimpleUrlHandlerMapping) for request handling, and MultiActionController bean is defined without
    "name" attribute! Check by yourself paragraph 13.3.3 of Spring Reference Documentation.

    Do I always need to add additional mapping to MultiActionController?

    Thanks in advance for answer.

  7. #7

    Default

    Hi rotbart,

    As far as my understanding goes, u always need to have a handler mapping defined in the context. If u dont define any handler mapping, DispatcherServlet creates the default handler mapping for u .

    In the spring documentation they have just shown how to configure the
    MultiActionController. U need to define the handler mapping if u want the control to be directed to your controller.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •