Announcement Announcement Module
Collapse
No announcement yet.
No mapping found (DispatcherServlet) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No mapping found (DispatcherServlet)

    Hello,

    I am new to Spring and facing a little trouble which I can't solve.

    I have following web.xml :

    Code:
      <servlet>
        <servlet-name>web</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    	   <param-name>contextConfigLocation</param-name>
    	   <param-value>/WEB-INF/conf/platform-web-context.xml</param-value>
    	</init-param>    
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <servlet-mapping>
        <servlet-name>web</servlet-name>
        <url-pattern>/do/*</url-pattern>      
      </servlet-mapping>

    and following spring config file :

    Code:
    
      <bean name="/do/CreateCustomer" class="com.myapp.web.controller.CreateCustomerCtl"/>        
     
      <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
           <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
           <property name="prefix" value="/WEB-INF/views/"></property>
           <property name="suffix" value=".jsp"></property>        
       </bean>
    Yet, when I call the URL http://localhost:8080/myapp/do/CreateCustomer, I have following message : "ATTENTION: No mapping found for HTTP request with URI [/myapp/do/CreateCustomer] in DispatcherServlet with name 'web'"

    If I change the url-pattern to "*.htm" and the bean name to "/doCreateCustomer.htm" then everything works fine... it seems it doesn't like the pattern /do/* ....

    Does anyone have an idea of what is wrong ?

    Many thanks

    Patrick

  • #2
    Hi patoch,

    Have you tried
    Code:
    <bean name="/CreateCustomer" class="com.myapp.web.controller.CreateCustomerCtl"/>
    It looks like your current config is trying to map /do/do/CreateCustomer to the controller.

    Josh

    Comment


    • #3
      Your real jsp file is named with "doXXXXXXXX" syntax. so your jsp file real path must be "/WEB-INF/views/doXXXXXXX.jsp". You can try it like this:
      web.xml
      Code:
        <servlet-mapping>
          <servlet-name>web</servlet-name>
          <url-pattern>/do*</url-pattern>      
        </servlet-mapping>
      Application Context Configuration
      Code:
      <bean name="/doCreateCustomer" class="com.myapp.web.controller.CreateCustomerCtl"/

      Comment


      • #4
        dakulaliu,

        I am not sure what you are on about, the controller can pass back what view should be displayed, no element of patochs problem 'must' be solved in the way you have described.

        Josh

        Comment


        • #5
          Hi Josh and Dakulaliu,

          thank you for your help. Actually, I followed Josh's suggestion to rename the bean to /CreateCustomer in spite of /do/CreateCustomer and it solved the problem !

          Many thanks again !

          Patrick

          Comment


          • #6
            Hi all,

            I have the same issue. I have not found what's wrong.

            Here is my 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 id="CIIM-Webapp">
            <display-name>Archetype Created Web Application</display-name>

            <servlet>
            <servlet-name>start</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
            <load-on-startup>1</load-on-startup>
            </servlet>

            <servlet-mapping>
            <servlet-name>start</servlet-name>
            <url-pattern>*.jsp</url-pattern>
            </servlet-mapping>

            <listener>
            <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
            </listener>

            <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/start-servlet.xml</param-value>
            </context-param>

            </web-app>

            And here is my Spring context file:

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
            "http://www.springframework.org/dtd/spring-beans.dtd">
            <beans>
            <bean name="/start.jsp" class="com.ehconsulting.controllers.StartControlle r"></bean>

            <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
            <!-- <property name="viewClass">-->
            <!-- <value>org.springframework.web.servlet.view.JstlVi ew</value>-->
            <!-- </property>-->
            <property name="prefix">
            <value>/WEB-INF/jsp/</value>
            </property>
            <property name="suffix">
            <value>.jsp</value>
            </property>
            </bean>
            </beans>

            Please, is someone can explain me where is the issue !?

            Regards.

            Comment

            Working...
            X