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

  • WebApplicationContext

    Hi all,
    Im a newbie using spring and i have a question.
    Im trying create a config.xml to my web application (foo), this config.xml will contain the handlerMapping and the viewResolver to theservlet ( DispatcherServlet).

    in my web.xml i put:
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/config.xml
    </param-value>
    </context-param>


    the config.xml will contain the beans definition
    <bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.Bea nNameUrlHandlerMapping"/>

    i thought that this was correct, but i saw that my definition was not loaded. Why ?
    The DispatcherServlet cannot get beans definitions outside the "app-servlet.xml" , the servlet create a new webApplicationContext only with definitions inside the "foo-servlet.xml" ? My controllers get definitions that i create outside "foo-servlet.xml" so why do not take my handlemapping outside too ?

  • #2
    Are you using a ContextLoaderListener, configured somewhere else in the web.xml? Are you using struts or tiles or some other servlet-type framework?

    Comment


    • #3
      cant load the config outside the servleSpring context

      Originally posted by khote View Post
      Are you using a ContextLoaderListener, configured somewhere else in the web.xml? Are you using struts or tiles or some other servlet-type framework?
      Im using ContextLoaderListener only in my web.xml to load my services and dao beans.

      WEB.XML

      Code:
      <context-param>
      		<param-name>contextConfigLocation</param-name>
      		<param-value>				   
      		   	classpath:applicationContext-service.xml,
      	    	        classpath:applicationContext-transaction-aop.xml
      		</param-value>
      </context-param>
      
      <listener>		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <servlet>
      
      <servlet-name>app</servlet-name>
      		 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      		<init-param>
      			<param-name>contextConfigLocation</param-name>
      			<param-value>
      				/WEB-INF/myapp-servlet.xml
      			</param-value>
      		</init-param>
      </servlet>
      So , as u can see, if a config a HandleMapping outisde the myapp-servlet.xml, my DispatcherServlet will not load.
      for example, if i put in contextConfigLocation a file that like applicationConfig.xml and inside this file put my viewResolver and my handleMapping, this will not work.




      And about servlet-type, just using Spring MVC.

      Thanks

      Comment

      Working...
      X