Simple Spring/Thymeleaf-App
[examples/maven-grunt-integration] / src / main / resources / spring / mvc.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4        xmlns:mvc="http://www.springframework.org/schema/mvc"
5        xmlns:context="http://www.springframework.org/schema/context"
6        xmlns:util="http://www.springframework.org/schema/util"
7        xsi:schemaLocation="
8            http://www.springframework.org/schema/beans
9            http://www.springframework.org/schema/beans/spring-beans.xsd
10            http://www.springframework.org/schema/mvc
11            http://www.springframework.org/schema/mvc/spring-mvc.xsd
12            http://www.springframework.org/schema/context
13            http://www.springframework.org/schema/context/spring-context.xsd
14            http://www.springframework.org/schema/util
15            http://www.springframework.org/schema/util/spring-util.xsd
16            ">
17
18   <!-- Resolve app-parameters through java-systemproperties -->
19   <context:property-placeholder location="classpath:maven-grunt-integration.properties" />
20
21   <!-- Needed, to map the servlet on /* -->
22   <mvc:default-servlet-handler/>
23   <mvc:view-controller path="/" view-name="index"/>
24
25   <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
26     <property name="mappings">
27       <value>
28         /thymeleaf/**=staticResources
29         /*.html=urlFilenameViewController
30         /**/*.html=urlFilenameViewController
31       </value>
32     </property>
33     <property name="order" value="10"/>
34   </bean>
35   <bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
36   <bean id="staticResources" class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler">
37     <property name="locations">
38       <list>
39         <value>/thymeleaf/</value>
40       </list>
41     </property>
42   </bean>
43
44   <!-- Thymeleaf Spring-View-Resolver -->
45   <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
46     <property name="templateEngine" ref="templateEngine" />
47     <property name="characterEncoding" value="UTF-8" />
48     <property name="contentType" value="text/html; charset=UTF-8" />
49   </bean>
50
51
52   <!-- Thymeleaf Template-Resolver -->
53   <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
54     <property name="prefix" value="/thymeleaf/" />
55     <property name="suffix" value=".html" />
56     <property name="templateMode" value="HTML5" />
57     <property name="characterEncoding" value="UTF-8" />
58     <property name="cacheable" value="${maven-grunt-integration.cacheable}" />
59   </bean>
60
61   <!-- Thymeleaf Spring4-Template-Engine -->
62   <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
63     <property name="templateResolver" ref="templateResolver" />
64     <property name="additionalDialects">
65       <util:set>
66         <bean class="nz.net.ultraq.thymeleaf.LayoutDialect"/>
67       </util:set>
68     </property>
69   </bean>
70
71 </beans>