ApplicationContext is a parent of WebApplicationContext .
But why and must palce in the same context then it will works ?
Here is my explain:
=============
I config my applicationConext.xml like this :
<context:component-scan base-package="com.github" />
<mvc:annotation-driven />
and none similar settings in dispatcher-servlet.xml.
It works!!!
===========
I config my dispatcher-servlet.xml like this :
<context:component-scan base-package="com.github" />
<mvc:annotation-driven />
and none similar settings in applicationConext.xml.
It also works!!!
==========
BUT , If i put <context:component-scan base-package="com.github" />
in applicationConext.xml and <mvc:annotation-driven />
in dispatcher-servlet.xml OR put <context:component-scan base-package="com.github" />
in dispatcher-servlet.xml and <mvc:annotation-driven />
in applicationConext.xml.
It doesnot work!!! return httpStatus 404,not found,that means it doesnot mapping to the Controller.
ApplicationContext is a parent of WebApplicationContext , the child context shoud inherit from the parent conext , so I thought the settings can separate in different context but not the same one !
Am I wrong ? Please anybody could answer me , thx !