@@ -1649,138 +1649,6 @@ is the default type.
1649
1649
1650
1650
1651
1651
1652
- [[mvc-view-tiles]]
1653
- == Tiles
1654
-
1655
- You can integrate Tiles - just as any other view technology - in web
1656
- applications that use Spring. This section describes, in a broad way, how to do so.
1657
-
1658
- NOTE: This section focuses on Spring's support for Tiles version 3 in the
1659
- `org.springframework.web.servlet.view.tiles3` package.
1660
-
1661
-
1662
-
1663
- [[mvc-view-tiles-dependencies]]
1664
- === Dependencies
1665
-
1666
- To be able to use Tiles, you have to add a dependency on Tiles version 3.0.1 or higher
1667
- and https://tiles.apache.org/framework/dependency-management.html[its transitive dependencies]
1668
- to your project.
1669
-
1670
-
1671
-
1672
- [[mvc-view-tiles-integrate]]
1673
- === Configuration
1674
-
1675
- To be able to use Tiles, you have to configure it by using files that contain definitions
1676
- (for basic information on definitions and other Tiles concepts, see
1677
- https://tiles.apache.org[]). In Spring, this is done by using the `TilesConfigurer`.
1678
- The following example `ApplicationContext` configuration shows how to do so:
1679
-
1680
- [source,xml,indent=0,subs="verbatim,quotes"]
1681
- ----
1682
- <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
1683
- <property name="definitions">
1684
- <list>
1685
- <value>/WEB-INF/defs/general.xml</value>
1686
- <value>/WEB-INF/defs/widgets.xml</value>
1687
- <value>/WEB-INF/defs/administrator.xml</value>
1688
- <value>/WEB-INF/defs/customer.xml</value>
1689
- <value>/WEB-INF/defs/templates.xml</value>
1690
- </list>
1691
- </property>
1692
- </bean>
1693
- ----
1694
-
1695
- The preceding example defines five files that contain definitions. The files are all
1696
- located in the `WEB-INF/defs` directory. At initialization of the `WebApplicationContext`,
1697
- the files are loaded, and the definitions factory are initialized. After that has
1698
- been done, the Tiles included in the definition files can be used as views within your
1699
- Spring web application. To be able to use the views, you have to have a `ViewResolver`
1700
- as with any other view technology in Spring: typically a convenient `TilesViewResolver`.
1701
-
1702
- You can specify locale-specific Tiles definitions by adding an underscore and then
1703
- the locale, as the following example shows:
1704
-
1705
- [source,xml,indent=0,subs="verbatim,quotes"]
1706
- ----
1707
- <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
1708
- <property name="definitions">
1709
- <list>
1710
- <value>/WEB-INF/defs/tiles.xml</value>
1711
- <value>/WEB-INF/defs/tiles_fr_FR.xml</value>
1712
- </list>
1713
- </property>
1714
- </bean>
1715
- ----
1716
-
1717
- With the preceding configuration, `tiles_fr_FR.xml` is used for requests with the `fr_FR` locale,
1718
- and `tiles.xml` is used by default.
1719
-
1720
- NOTE: Since underscores are used to indicate locales, we recommended not using
1721
- them otherwise in the file names for Tiles definitions.
1722
-
1723
-
1724
-
1725
- [[mvc-view-tiles-url]]
1726
- ==== `UrlBasedViewResolver`
1727
-
1728
- The `UrlBasedViewResolver` instantiates the given `viewClass` for each view it has to
1729
- resolve. The following bean defines a `UrlBasedViewResolver`:
1730
-
1731
- [source,xml,indent=0,subs="verbatim,quotes"]
1732
- ----
1733
- <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
1734
- <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
1735
- </bean>
1736
- ----
1737
-
1738
-
1739
- [[mvc-view-tiles-preparer]]
1740
- ==== `SimpleSpringPreparerFactory` and `SpringBeanPreparerFactory`
1741
-
1742
- As an advanced feature, Spring also supports two special Tiles `PreparerFactory`
1743
- implementations. See the Tiles documentation for details on how to use
1744
- `ViewPreparer` references in your Tiles definition files.
1745
-
1746
- You can specify `SimpleSpringPreparerFactory` to autowire `ViewPreparer` instances based on
1747
- specified preparer classes, applying Spring's container callbacks as well as applying
1748
- configured Spring BeanPostProcessors. If Spring's context-wide annotation configuration has
1749
- been activated, annotations in `ViewPreparer` classes are automatically detected and
1750
- applied. Note that this expects preparer classes in the Tiles definition files, as
1751
- the default `PreparerFactory` does.
1752
-
1753
- You can specify `SpringBeanPreparerFactory` to operate on specified preparer names (instead
1754
- of classes), obtaining the corresponding Spring bean from the DispatcherServlet's
1755
- application context. The full bean creation process is in the control of the Spring
1756
- application context in this case, allowing for the use of explicit dependency injection
1757
- configuration, scoped beans, and so on. Note that you need to define one Spring bean definition
1758
- for each preparer name (as used in your Tiles definitions). The following example shows
1759
- how to define a `SpringBeanPreparerFactory` property on a `TilesConfigurer` bean:
1760
-
1761
- [source,xml,indent=0,subs="verbatim,quotes"]
1762
- ----
1763
- <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
1764
- <property name="definitions">
1765
- <list>
1766
- <value>/WEB-INF/defs/general.xml</value>
1767
- <value>/WEB-INF/defs/widgets.xml</value>
1768
- <value>/WEB-INF/defs/administrator.xml</value>
1769
- <value>/WEB-INF/defs/customer.xml</value>
1770
- <value>/WEB-INF/defs/templates.xml</value>
1771
- </list>
1772
- </property>
1773
-
1774
- <!-- resolving preparer names as Spring bean definition names -->
1775
- <property name="preparerFactoryClass"
1776
- value="org.springframework.web.servlet.view.tiles3.SpringBeanPreparerFactory"/>
1777
-
1778
- </bean>
1779
- ----
1780
-
1781
-
1782
-
1783
-
1784
1652
[[mvc-view-feeds]]
1785
1653
== RSS and Atom
1786
1654
0 commit comments