java - How do the different contexts in Spring MVC work? -
i have following configuration spring mvc webapp. know conceptually difference between contextconfiglocation in servlet-context.xml (its conf appservlet) , others files security, tiles... don't understand how works because if put tiles-context.xml configuration in servlet-context app works , in other case no, security working properly. beans in files aren't in appservlet container also? there more 1 context?
<!-- dispatcherservlet conf - processes application requests --> <servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>classpath:servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- spring configuration files in xml --> <context-param> <param-name>contextconfiglocation</param-name> <param-value> classpath:security-context.xml classpath:tiles-context.xml ... </param-value> </context-param>
take on
spring root application context , servlet context confusion
what difference between applicationcontext , webapplicationcontext in spring mvc?
for difference root context , servlet context.
you can define multiple servlet context configuration follows
<servlet> <servlet-name>api-dispatcher</servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/api-dispatcher-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>api-dispatcher</servlet-name> <url-pattern>/rest/*</url-pattern>
above context accessible when url pattern /rest/*. how multiple separate context configured on spring.
Comments
Post a Comment