Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Having discussed the design details, let's proceed to the configuration of the SpringBlog application. In the following sections, we will discuss the various configurations of the application, from web deployment descriptor to Spring's WebApplicationContext hierarchy.
Let's take a look on the web deployment descriptor (web.xml), which is shown in Listing 21-6.
Listing 21-6. The web.xml File
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<!-- Enable escaping of form submission contents -->
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.active</param-name>
<!-- Spring profile parameters
First profile: jpa - JPA implementation
mybatis - MyBatis implementation
Second profile: mysql - MySQL DB
h2 - H2 database
-->
<param-value>jpa,h2</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml
/WEB-INF/spring/datasource.xml
/WEB-INF/spring/batch-context.xml
/WEB-INF/spring/*-tx-config.xml
/WEB-INF/spring/*-service-context.xml
</param-value>
</context-param>
<!-- Spring Security Configuration -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>