Announcement Announcement Module
Collapse
No announcement yet.
Could annotation based and xml based configuration be used together in spring 2.5? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could annotation based and xml based configuration be used together in spring 2.5?

    Hi

    I've been working on a project where controllers have been written extending Controller classes. Could I configure and use the POJO based Controllers as well (using @Controller) in the same application?

    Many thanks

  • #2
    Could annotation based and xml based configuration be used together in spring 2.5?

    Many thanks jamestastic, I've got it resolved for now

    Below are the lines needed to to be addeded to the web configuration file to have them working together:
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"  
           xmlns:context="http://www.springframework.org/schema/context"                    ...line1
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd                        
                http://www.springframework.org/schema/context                           ...line2
            http://www.springframework.org/schema/context/spring-context-2.5.xsd">  ...line3
    
    
    
        <context:annotation-config/>   ...line4
    
        <context:component-scan base-package="myPackage"/>  ...line5
    
        <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>  ...line6
    
        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>   ...line7
    
        <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>  ...line8
    
    </beans>
    I was too careless to not to add line 8 in my application.

    Many thanks

    Comment

    Working...
    X