最近闲着无事,琢磨了一下struts2.06的tiles使用。以下是一些简单使用的步骤。
1.在WEB-INF/lib下加入所需的jar包
commons-digester-1.6.jar,
xwork-2.0.1.jar,
tiles-core-2.0-20070207.130156-4.jar,
tiles-api-2.0-20070207.130156-4.jar,
struts2-tiles-plugin-2.0.6.jar,
struts2-core-2.0.6.jar
2.修改web.xml 为以下内容
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.apache.tiles.listener.TilesListener</listener-class>
</listener>
</web-app>
3.在WEB-INF下添加tiles.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://struts.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="showcase.index" template="/tiles/layout.jsp">
<put name="title" value="Tiles Showcase"/>
<put name="header" value="/tiles/header.jsp"/>
<put name="body" value="/tiles/body.jsp"/>
</definition>
</tiles-definitions>
4.struts.xml 为:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.ui.theme" value="simple" />
<include file="struts-conf/struts-test.xml" />
</struts>
5.struts-test.xml文件为:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="test" namespace="/test" extends="tiles-default">
<!-- <result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types> -->
<global-results>
<result name="login"><param name="location">/user/login.jsp</param></result>
</global-results>
<action name="sample" class="com.lhx.test.action.TilesAction" method="inputIndex" >
<result name="success" type="tiles">showcase.index</result>
</action>
</package>
</struts>
6.注意要在每个jsp文件中加入<%@ page contentType="text/html; charset=UTF-8"%>
分享到:
相关推荐
struts2.0.6+spring2.0.3+hibernane3的配置
Tomcat5.5+struts2+Spring2.0.6+Hibernate3图书进行管理的系统
springboot2.0.6+mybatis+mysql+分页+日志+web+模板页面+属性参数,可以直接作为项目框架进行开发
NULL 博文链接:https://8366.iteye.com/blog/476923
最新版本Struts2.1.8+Spring3.0+Hibernate3.3.2+DWR2.0.6配置,为web开发提供骨架!
iperf for window + android 2.0.6+3.1 版本合集 iperf Jperf 版本: window android apk
新版SSH+DWR配置(Struts2.1.8+Spring3.0+Hibernate3.3.2+DWR2.0.6) 很好的整合示例 目前最新框架整合
struts2发布已经很久了,但关于如何使用它的教程及实例并不多。特别是与Spring及Hibernate等流行框架的集成,并不多见。现在就将笔者使用Myeclipse工具应用struts2 + spring2 + hibernate3 实现CRUD操作的步骤一一...
struts2.0.6 基本的5个类包
还在为找不到jar文件烦心吗,不用了到我空间来有你想要的,持续更新。。。 tiles-api-2.0.6.jar,tiles-core-2.0.6.jar,tiles-jsp-2.0.6.jar
struts2.0.6的helloworld教程
压缩包中包含TriLib两个版本v2.0.6 和V1.8.7;可以运行时加载外部模型(fbx、obj、zip、url)等
折腾了一下午,再报了各种错误之后终于把SSH+tiles的整合的JAR包给搞定了。 SSH的版本如下: Struts-2.3.4 Spring-2.0.6 Hibernate-3.6.10 里面还有连数据库的jar---mysql-connector-java-5.1.12-bin.jar 最后启动...
薅羊毛拼团商城是一款以拼团为形式让消费者薅商家羊毛的微信小程序源码。 1、怎么玩? 多人拼团,部分人获得得商品,没获得商品的人退款并瓜分红包,红包佣金从获得商品的人的订单利润里返。 2、参与拼团的人需要...
现在就将笔者使用Myeclipse工具应用struts2 + spring2 + hibernate3 实现CRUD操作的步骤一一纪录下来,为初学者少走弯路略尽绵薄之力!在本文中,笔者将Struts2.0.6、Spring2.0.6和Hibernate3.1进行整合,希望通过...
本演示示例主要使用目前最新,最流行技术Struts2.1 +Spring 2.5.1+ibatis2.3整合开发而成,这与我以前发布的版本中最大特色是整合了Spring2.5.1中的注解功能和半自动化工具ibatis技术,这是本示例的两大特色,简化了配置...
NULL 博文链接:https://31841814.iteye.com/blog/1124111
包含struts2-core api和webwork2 api
Struts 2 Core 2.0.6 API Struts 2 Core 2.0.6 API
使用最新的Strust2.0.12 和Tiles2.0.6