General spring configuration file applicationcontext
. Xml
PATH is WEB-INF/
Or under SRC
However, when I use the main () function for testing:
// Put under webroot/WEB-INF, test
Applicationcontext
Act = new filesystemxmlapplicationcontext ("/webroot/WEB-INF/applicationcontext
. Xml
");
<!
-- Load spring injection for DWR -->
<Context-param>
<Param-Name> contextconfiglocation </param-Name>
<Param-value> classpath:/WEB-INF/applicationcontext. xml </param-value>
</Context-param>
<Listener>
<Listener-class>
Org. springframework. Web. Context. contextloaderlistener
</Listener-class>
</Listener>
You can also copy the configuration file to the src directory.
Applicationcontext
Act = new classpathxmlapplicationcontext ("applicationcontext
. Xml
");
<!
-- Load spring injection for DWR -->
<Context-param>
<Param-Name> contextconfiglocation </param-Name>
<Param-value> classpath: applicationcontext. xml </param-value>
</Context-param>
<Listener>
<Listener-class>
Org. springframework. Web. Context. contextloaderlistener
</Listener-class>
</Listener>
---------------------
For classpathxmlapplicationcontext ()
The default value is under the classpath path of the project.
Classpath:
Prefix is not required
If you want to use an absolute path, you must add file: prefix to indicate that this is an absolute path.
For filesystemxmlapplicationcontext ()
Two types are represented by default.
1. If there is no drive letter, yes
Project Working path, that is, the root directory of the project
2. A drive letter indicates the absolute file path.
To use the classpath path, you must prefix classpath: