Spring MVC: Does this code make child-parent relationship between two context? -


i have learned how configure spring mvc without web.xml , .xml files parent , child context link. saw how programmatically make context hierarchy in the official spring docs follow.

applicationcontext parent = new genericxmlapplicationcontext(parentannotationconfig.class); genericapplicationcontext child = new genericapplicationcontext(parent); 

but post the link don't have similar statements above ones. code make context hierarchy between 2 context or not?

the code link submitted uses spring mvc. programmatic method show independant of spring mvc. makes big difference.

spring mvc automagically creates parent child relations between root context , dispatcher servlet context(es). wepapp should have :

  • one single root context referenced in servletcontext. supposed used not directly related servlet : model, persistance , filters can exist independantly of servlet
  • one context per dispatcher servlet constructed root context parent. supposed used controllers, views, interceptors

the parent-child relation ensure can access beans controllers, cannot access web (servlet) beans root contex.

to directly answer question, linked code not explicitely build context hierachy. hierarchy built spring mvc framework. exist, , must not try generate explicetely.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -