Results 1 to 3 of 3

Thread: org.springframework.web.servlet.DispatcherServlet noHandlerFound (No mapping found)

  1. #1
    Join Date
    Oct 2011
    Posts
    18

    Default org.springframework.web.servlet.DispatcherServlet noHandlerFound (No mapping found)

    my jsps are under WEB-INF/jsp/ , and following is my web.xml:

    Code:
    <!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>
          <display-name>Checkout</display-name>
          
          <servlet>
            <servlet-name>myservlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
          </servlet>
        
          <servlet-mapping>
            <servlet-name>myservlet</servlet-name>
            <url-pattern>*.action</url-pattern>
          </servlet-mapping>
           
          
        </web-app>
    and here's mapping of page product.jsp which i am trying to access:

    Code:
    @Controller
        @RequestMapping("/product.action")
        public class ProductController {
        	
        	/**
        	 * Show the product selection form
        	 * 
        	 * @return
        	 */
        	@RequestMapping(method=RequestMethod.GET)
        	public String get() {
        		return "products.jsp";
        	}
        
        }
    when trying to access the page from the following link:

    Code:
    http://localhost:8080/myapp/product.action
    i am getting `404` in the browser, and i get the following warning in the console:

    Code:
     Jun 28, 2012 10:55:23 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
        WARNING: No mapping found for HTTP request with URI [/myapp/product.action] in DispatcherServlet with name 'myservlet'

    i tried adding the viewResolver bean to applicationContext with no luck:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
        <beans xmlns="http://www.springframework.org/schema/beans"
        	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        	xmlns:context="http://www.springframework.org/schema/context"
        	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
            
            <context:component-scan base-package="com.myapp"/>
            
            
        
            <bean id="viewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/jsp/"/>
            <property name="suffix" value=".jsp"/>
           </bean>
            
        
        </beans>

    am i missing something in the configuration ?
    please advise, thanks.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Have you READ the error?

    It is about noHandlerFound not about a missing view...

    Crank up your logging to debug and see if your controller is detected I suspect not. Try adding a mvc:annotation-driven.
    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

  3. #3
    Join Date
    Oct 2011
    Posts
    18

    Default

    you are right,controller was not detected, i changed the base package from com.myapp to com.myapp.controller, and it works fine now.

    but since com.myapp contains com.myapp.controller, then com.myapp should work fine as base-package i guess, what do you think ?

Tags for this Thread

Posting Permissions

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