Announcement Announcement Module
Collapse
No announcement yet.
annotation mapping config Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • annotation mapping config

    Dear All,

    Here is my controller annotation

    @Controller
    @RequestMapping("/manage_something.do")
    @SessionAttributes("form")
    public class ManageSomethingFormController {

    }


    Error Message: WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/MTS_TEST/manage_something.do] in DispatcherServlet with name 'dispatcher'.

    It will work if I add the mapping in the servlet.xml
    <property name="mappings">
    <value> manage_something.do=manageSomethingFormController </value>
    </property>


    I thought the whole point of annotation controller is to get rid of the XML mapping including the url mapping completely.Could anyone help me figure out what I missed? Thank very much in advance.

    Here are the config in dispatcher-servlet.xml and web.xml.

    -------------------------------------------------------------

    dispatcher-servlet.xml

    <?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"

    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:component-scan base-package="where/controller/are" />

    ------------------------------------------------------------------
    web.xml

    <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <!-- Location of web application configuration for Spring -->
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/conf/dispatcher-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Route all URLs ending in .do to the dispatcher servlet -->
    <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

  • #2
    I tried to register these two beans in servlet.xml because there are many exsiting controllers are not annotated and still using SimpleUrlHandlerMapping in the servlet.xml for the url mapping.

    <bean class="org.springframework.web.servlet.mvc.annotat ion. DefaultAnnotationHandlerMapping" />

    <bean class="org.springframework.web.servlet.mvc.annotat ion. AnnotationMethodHandlerAdapter" />


    After adding the two beans, all existing non-anotated controllers stopped working. Here is the error messages.

    ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TEST].[dispatcher] - Servlet.service() for servlet dispatcher threw exception
    javax.servlet.ServletException: No adapter for handler [uk.ac.sanger.mig.security.controllers.LoginFormCon troller@5d626b]: Does your handler implement a supported interface like Controller?
    Last edited by 7of9; Dec 23rd, 2010, 04:43 AM.

    Comment


    • #3
      problem solved by myself. remove the AnnotationMethodHandlerAdapter, but leave the DefaultAnnotationHandlerMapping in

      Comment

      Working...
      X