Results 1 to 3 of 3

Thread: Using annotation-based controller

  1. #1
    Join Date
    Oct 2009
    Posts
    3

    Default Using annotation-based controller

    Hi,
    I'm having some trouble when using @Controller. I'm getting
    WARN [org.springframework.web.servlet.PageNotFound] - <No mapping for [/call.omri] in DispatcherServlet with name 'springMVC'>
    applicationContext.xml:
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:p="http://www.springframework.org/schema/p"
            xmlns:aop="http://www.springframework.org/schema/aop"
            xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="http://www.springframework.org/schema/aop  
                http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    		http://www.springframework.org/schema/beans       
                http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    
     
            <!-- Auto detect controllers with @Controller -->
        <context:component-scan base-package="com.web.controller"/>
    My controller is:

    Code:
    @Controller
    public class ClassificationsController   {
    
        public ClassificationsController() {}
    
        private ClassificationsManager cacheReference;
    
        @RequestMapping("/call.omri")
        public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
           Some code...
            return null;
        }        
    }

    I've tried using
    Code:
                 <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
    
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
    in web-context.xml (dispatcher servlet context) but still same thing.
    I also tried using @RequestMapping on the controller itself (and not on a specific method) but still nothing.

    Any help would be appreciated.
    Thanks.

  2. #2
    Join Date
    Nov 2006
    Location
    Columbus, OH
    Posts
    143

    Default

    You should put

    Code:
            <!-- Auto detect controllers with @Controller -->
        <context:component-scan base-package="com.web.controller"/>
    in your dispatcher-servlet.xml file instead of your applicationContext.xml file.

    Hope that helps,
    Regards,

    Joshua Preston

    --

    "The Guide says that there is an art to flying," said Ford, "or rather a knack. The knack lies in learning how to throw yourself at the ground and miss."

  3. #3
    Join Date
    Oct 2009
    Posts
    3

    Default

    Thanks for reply.
    I've done as you said but still nothing...
    I'm getting
    Code:
    2009-10-08 06:45:53,561 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@a7fab1: defining beans [classificationsController,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,/all_profiles.html,/new_profile_wizard.html,viewResolver]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@7ca7f0>
    so the controller (classificationsController) gets loaded... Somehow, the dispatcher servlet can't figure the mapping..
    Any ideas?

    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
  •