当前位置:首页 > 开发 > 编程语言 > Spring > 正文

Spring 3.2 + Apache Tiles 3

发表于: 2013-03-18   作者:cntsai   来源:转载   浏览:
摘要: controller @Controller public class LoginController { @RequestMapping(value = "/login", method = RequestMethod.GET) public ModelAndView getContent() { ModelAndView view = ne
controller
@Controller
public class LoginController {

	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public ModelAndView getContent() {

		ModelAndView view = new ModelAndView("loginView");

		return view;
	}
}

spring-servlet.xml
	<bean id="tilesConfigurer"
		class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
		<property name="definitions">
			<list>
				<value>/WEB-INF/tiles.xml</value>
			</list>
		</property>
		<property name="preparerFactoryClass"
			value="org.springframework.web.servlet.view.tiles3.SpringBeanPreparerFactory" />
	</bean>
	
	<bean id="tilesViewResolver"
		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
		<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
	</bean>


tiles.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
       "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
	<definition name="base.definition" template="/WEB-INF/jsp/layout.jsp">
		<put-attribute name="title" value="" />
		<put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
		<put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
		<put-attribute name="body" value="" />
		<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
	</definition>

	<definition name="loginView" extends="base.definition">
		<put-attribute name="title" value="Login Page" />
		<put-attribute name="body" value="/WEB-INF/jsp/login.jsp" />
	</definition>

</tiles-definitions>


Apache Tiles in web.xml - Starting Tiles engine
If you use springframework, does not need to do it.

If you want to configure multiple view resolvers in spring MVC
Configure Multiple View Resolvers Priority In Spring MVC


Spring 3 MVC: Tiles Plugin Tutorial with Example in Eclipse

Spring 3.2 + Apache Tiles 3

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号