GitHub: https://github.com/SylkeWay/synthful
First, look at the web app definition file:
/durian/src/main/webapp/WEB-INF/web.xml .
web-app enclosure
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
- As stated previously, this project uses servlet 3.1 .
- Note that servlet 2.5 onwards, any occurrences of {j2ee} in all its namespaces have been replaced with {javaee}.
Spring context bootstrap
web.xml provides the facility to specify bootstrap classes. Spring's ContextLoaderListener class is needed to be bootstrapped to perform its component based actions.
<listener> <listener-class> org.springframework.web.context.ContextLoaderListener <</listener-class> </listener>
Custom location of Spring configuration files
The location of all the text and data files are consolidated under the source folder
[src/main/resources]
Spring, not including webmvc, configuration files are placed under
[src/main/resources]/spring
Therefore, Spring should be notified through the {contextConfigLocation} parameter that such configuration files should be found in the classpath
/spring/ .
<context-param> <param-name>contextConfigLocation<</param-name> <param-value>classpath:/spring/**-context.xml</param-value> </context-param>
i.e. whose names end with
-context.xml .
The parameter value must define a namespace that is accessible by the web app during run-time. Which could either be
- classpath:{a classpath commalist}
- a plain folder path rooted from the web app context root, e.g.,
WEB-INF/
Spring mvc bootstrap
Since Spring webmvc operates on the servlet frontend (i.e. frontend of the server side, not the client frontend), its component-action bootstrap is a servlet: org.springframework.web.servlet.DispatcherServlet .
<servlet> <servlet-name>mvc-dispatcher <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/springweb/**-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
Similarly, the webmvc bootstrap servlet would look for components through a context configuration file, and therefore too has its own {contextConfigLocation} parameter, to instruct Spring webmvc to look for all its context configuration files under the classpath
/springweb/
.
No comments:
Post a Comment