SSM Framework integration has been reported that did not create an instance bean error, always thought is the code reason, repeated testing for a long time, only to find the reason is the spring configuration file is not imported correctly, is my error example
Web. Xml the way the spring configuration file is loaded depends mainly on the name of the profile and the location in which it is stored, and there are two main ways.
1. If the spring configuration file name is Applicationcontext.xml and is stored in the web-inf/directory, simply add the following code to the Web. xml
<listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class ></listener>
This listener automatically scans the APPLICATIONCONTEXT.XRNL file under web-inf/, which is mostly used in cases where there is only one configuration file.
You can also use this special servlet of spring Contextloaderservlet to implement the following code
<servlet> <servlet-name>context</servlet-name> <servlet-class> Org.springframework.web.context.contextloaderservlet</servlet-name>
<load-on-startup>1 (smaller numbers will do) </load-on-startup>
</servlet>
Both of the above are possible, but there are some differences.
2. If the name of the spring configuration file is a custom other name, such as Applicationcontext-test.xml, or in the web-inf/directory, you also need to configure the Contextconfiglocation parameter, This parameter is a string that the listener or servlet will customize to parse the string into multiple files by a specific character (such as a space, comma, semicolon). You need to add the following code:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/web-inf/ application-testa.xml,/web-inf/application-testb.xml,/web-inf/application-testb.xml</param-value></ Context-param>
If this is a problem, you can use wildcards to abbreviate the
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/web-inf/ Application*.xml</param-value></context-param>
Then add the above listener or servlet code to it.
3. If neither the Applicationcontext.xml file nor the Contextconfiglocation parameter is used to determine the configuration file, or the configuration file Contextconfiglocation determined does not exist. Will cause spring to fail to load the configuration file or to create the ApplicationContext instance correctly.
Correct example
Reprint: http://www.cnblogs.com/zjhs/archive/2012/10/26/2741228.html
How the spring configuration file is loaded correctly in Web. xml