- 浏览: 2552412 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
tiles2的布局管理(二)struts2+tiles2
official web site
http://tiles.apache.org/
the document is here
http://tiles.apache.org/framework/index.html
Since spring is not used in our project, so we manage tiles like this.
configuration file web.xml:
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
since we do not use spring here, so the properties file only leaving the struts config, struts.properties:
struts.i18n.encoding=utf-8
#dev mode flag
struts.devMode=true
struts.action.extension=do
I never changed the tiles.xml file:
<?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="base.definition" template="/layout/layout.jsp">
<put-attribute name="title" value="当前客户起始页面"/>
<put-attribute name="banner" value="/content/top.jsp"/>
<put-attribute name="menu" value="/content/menu.jsp"/>
<put-attribute name="sidebar" value="/content/sidebar.jsp"/>
<put-attribute name="hintbar" value="/content/error.jsp"/>
<put-attribute name="body" value="/screen/body.jsp"/>
</definition>
<definition name="index.definition" extends="base.definition">
<put-attribute name="body" value="/screen/index.jsp"/>
</definition>
</tiles-definitions>
and I change the struts.xml to use java bean instead of spring bean:
<?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="testp" namespace="/testn" extends="tiles-default">
<action name="hello" method="hello"
class="com.sillycat.easytiles.action.HelloAction">
<result name="hello" type="tiles">base.definition</result>
</action>
<action name="ads" method="ads"
class="com.sillycat.easytiles.action.HelloAction">
<result name="hello" type="tiles">index.definition</result>
</action>
</package>
</struts>
and the action is extends from ActionSupport, not spring controller, HelloAction.java:
package com.sillycat.easytiles.action;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class HelloAction extends ActionSupport{
private static final long serialVersionUID = -9057233877588668059L;
private Map<String, Object> request;
private Map<String, Object> session;
private Map<String, Object> application;
private String ctx = null;
public String getCtx() {
if (ctx == null) {
HttpServletRequest request = ServletActionContext.getRequest();
ctx = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort();
ctx += request.getContextPath();
}
return ctx;
}
@SuppressWarnings("unchecked")
public String hello() {
request = (Map) ActionContext.getContext().get("request");
session = ActionContext.getContext().getSession();
application = ActionContext.getContext().getApplication();
request.put("request1", "request-test2");
session.put("session1", "session-test2");
application.put("application1", "application-test2");
return "hello";
}
@SuppressWarnings("unchecked")
public String ads() {
request = (Map) ActionContext.getContext().get("request");
session = ActionContext.getContext().getSession();
application = ActionContext.getContext().getApplication();
request.put("request1", "request-test1");
session.put("session1", "session-test1");
application.put("application1", "application-test1");
ctx = "http://sillycat.iteye.com";
return "hello";
}
}
nothing special, we still use this url to visit our pages.
<a href="testn/testp/hello.do">hello</a><br />
<a href="testn/testp/ads.do">ads</a><br />
everything runs well.
official web site
http://tiles.apache.org/
the document is here
http://tiles.apache.org/framework/index.html
Since spring is not used in our project, so we manage tiles like this.
configuration file web.xml:
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
since we do not use spring here, so the properties file only leaving the struts config, struts.properties:
struts.i18n.encoding=utf-8
#dev mode flag
struts.devMode=true
struts.action.extension=do
I never changed the tiles.xml file:
<?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="base.definition" template="/layout/layout.jsp">
<put-attribute name="title" value="当前客户起始页面"/>
<put-attribute name="banner" value="/content/top.jsp"/>
<put-attribute name="menu" value="/content/menu.jsp"/>
<put-attribute name="sidebar" value="/content/sidebar.jsp"/>
<put-attribute name="hintbar" value="/content/error.jsp"/>
<put-attribute name="body" value="/screen/body.jsp"/>
</definition>
<definition name="index.definition" extends="base.definition">
<put-attribute name="body" value="/screen/index.jsp"/>
</definition>
</tiles-definitions>
and I change the struts.xml to use java bean instead of spring bean:
<?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="testp" namespace="/testn" extends="tiles-default">
<action name="hello" method="hello"
class="com.sillycat.easytiles.action.HelloAction">
<result name="hello" type="tiles">base.definition</result>
</action>
<action name="ads" method="ads"
class="com.sillycat.easytiles.action.HelloAction">
<result name="hello" type="tiles">index.definition</result>
</action>
</package>
</struts>
and the action is extends from ActionSupport, not spring controller, HelloAction.java:
package com.sillycat.easytiles.action;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class HelloAction extends ActionSupport{
private static final long serialVersionUID = -9057233877588668059L;
private Map<String, Object> request;
private Map<String, Object> session;
private Map<String, Object> application;
private String ctx = null;
public String getCtx() {
if (ctx == null) {
HttpServletRequest request = ServletActionContext.getRequest();
ctx = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort();
ctx += request.getContextPath();
}
return ctx;
}
@SuppressWarnings("unchecked")
public String hello() {
request = (Map) ActionContext.getContext().get("request");
session = ActionContext.getContext().getSession();
application = ActionContext.getContext().getApplication();
request.put("request1", "request-test2");
session.put("session1", "session-test2");
application.put("application1", "application-test2");
return "hello";
}
@SuppressWarnings("unchecked")
public String ads() {
request = (Map) ActionContext.getContext().get("request");
session = ActionContext.getContext().getSession();
application = ActionContext.getContext().getApplication();
request.put("request1", "request-test1");
session.put("session1", "session-test1");
application.put("application1", "application-test1");
ctx = "http://sillycat.iteye.com";
return "hello";
}
}
nothing special, we still use this url to visit our pages.
<a href="testn/testp/hello.do">hello</a><br />
<a href="testn/testp/ads.do">ads</a><br />
everything runs well.
发表评论
-
Update Site will come soon
2021-06-02 04:10 1679I am still keep notes my tech n ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 431Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 374Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 455VPN Server 2020(2)Docker on Cen ... -
Nginx Deal with OPTIONS in HTTP Protocol
2020-02-15 01:33 356Nginx Deal with OPTIONS in HTTP ... -
PDF to HTML 2020(1)pdftohtml Linux tool or PDFBox
2020-01-29 07:37 405PDF to HTML 2020(1)pdftohtml Li ... -
Elasticsearch Cluster 2019(2)Kibana Issue or Upgrade
2020-01-12 03:25 720Elasticsearch Cluster 2019(2)Ki ... -
Spark Streaming 2020(1)Investigation
2020-01-08 07:19 295Spark Streaming 2020(1)Investig ... -
Hadoop Docker 2019 Version 3.2.1
2019-12-10 07:39 295Hadoop Docker 2019 Version 3.2. ... -
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 241MongoDB 2019(3)Security and Aut ... -
MongoDB 2019(1)Install 4.2.1 Single and Cluster
2019-11-11 05:07 294MongoDB 2019(1) Follow this ht ... -
Monitor Tool 2019(1)Monit Installation and Usage
2019-10-17 08:22 325Monitor Tool 2019(1)Monit Insta ... -
Ansible 2019(1)Introduction and Installation on Ubuntu and CentOS
2019-10-12 06:15 312Ansible 2019(1)Introduction and ... -
Timezone and Time on All Servers and Docker Containers
2019-10-10 11:18 332Timezone and Time on All Server ... -
Kafka Cluster 2019(6) 3 Nodes Cluster on CentOS7
2019-10-05 23:28 283Kafka Cluster 2019(6) 3 Nodes C ... -
K8S Helm(1)Understand YAML and Kubectl Pod and Deployment
2019-10-01 01:21 326K8S Helm(1)Understand YAML and ... -
Rancher and k8s 2019(5)Private Registry
2019-09-27 03:25 362Rancher and k8s 2019(5)Private ... -
Jenkins 2019 Cluster(1)Version 2.194
2019-09-12 02:53 444Jenkins 2019 Cluster(1)Version ... -
Redis Cluster 2019(3)Redis Cluster on CentOS
2019-08-17 04:07 373Redis Cluster 2019(3)Redis Clus ...
相关推荐
总之,"struts2.2+velocity+tiles+spring3+mybatis3.05整合"实例展示了Java Web开发中的典型技术栈集成,为开发者提供了高效、稳定的开发环境,有助于提升项目开发的速度和质量。通过学习和实践这个实例,开发者可以...
Struts2是基于MVC(Model-View-Controller)设计模式的开源框架,而Tiles则是Struts2的一个视图层扩展,它提供了一种方式来组织和重用页面布局,使得页面设计更加模块化。 Struts2框架的核心特性包括: 1. **Action...
将Tiles与Struts2结合使用,可以更有效地管理和组织网页布局,实现复杂的页面结构和重用内容。在本篇文章中,我们将深入探讨如何在Struts2中集成Tiles框架,以及如何利用它来展示信息。 首先,我们来理解一下Tiles...
在Java Web开发中,Struts2是一个非常流行的MVC(模型-视图-控制器)框架,而Tiles则是用于构建复杂的Web页面布局的框架。这两者的结合可以极大地提高开发者的工作效率和应用的用户体验。本篇文章将深入探讨如何在...
Tiles库则是Struts2中的一个强大的视图管理组件,用于组织和重用页面布局。本文将深入探讨Struts2标签和Tiles库的使用,以及它们在实际开发中的应用。 1. **Struts2标签** Struts2提供了丰富的标签库,这些标签...
Struts 是一个用于构建 MVC(模型-视图-控制器)架构的应用框架,Hibernate 是一个对象关系映射(ORM)工具,Spring 提供了一个全面的企业级应用开发框架,而 Tiles 主要用于页面布局和视图管理。 **Struts框架**:...
而tiles插件则为Struts2提供了强大的页面布局管理功能,使得开发者能够更容易地管理和复用页面布局。 ### 1. Struts2与tiles插件简介 Struts2的核心优势在于其灵活性和可扩展性,它允许开发者使用各种不同的技术来...
Struts2、Spring、Tiles和Log4j是Java Web开发中的四大核心框架,它们共同构建了一个强大且灵活的基础架构,适用于构建复杂的企业级应用程序。以下将详细解释这四个框架及其在实际开发中的应用。 **Struts2框架**:...
4. **Tiles布局(Layout)** 布局是定义的一种特殊形式,它定义了页面的整体框架,通常包括页头、主体、页脚等部分。页面内容可以通过引用不同的定义来填充布局的不同部分。 5. **Tiles配置(Configuration)** ...
3. **Action结果映射**:在Action类的execute方法中,返回一个Tiles定义的名称,Struts2会根据这个名称找到对应的布局和内容进行渲染。 4. **JSP页面**:使用Tiles标签库在JSP页面中引用组件,如`<tiles:insert...
首先,`tiles2`是Apache Tiles框架的一个版本,它允许开发者定义和管理Web应用中的页面布局。Tiles2通过模板和组件的方式,让开发者可以创建可复用的页面部分,从而提高开发效率并保持代码的整洁。 **Step1: 导入...
Struts1中的Tiles标签库是一种强大的布局管理工具,旨在提高Web应用的可重用性、可扩展性和可维护性。Tiles框架是Apache Software Foundation发起的一个开源项目,它为开发者提供了创建复合式网页的能力,允许在运行...
通过Struts2和Tiles的集成,开发者可以更方便地管理页面结构,实现页面的复用和模块化。同时,Struts2的Action和Interceptor机制能够很好地控制业务流程,两者结合可以提供一套强大的Web应用开发解决方案。记住,...
总结一下,集成Struts2和Tiles2的关键步骤包括:引入依赖库、配置Struts2和Tiles2的配置文件、定义页面布局和组件、在Action中返回Tiles定义名。通过这种方式,开发者可以更好地组织和管理Web应用的视图部分,同时...
4. **Tiles插件**:用于创建复杂的布局,可复用的页面片段,便于构建大型应用。 5. **国际化(i18n)**:Struts2支持多语言,通过资源包轻松实现不同语言的切换。 Hibernate的核心概念包括: 1. **实体(Entity)...
Tiles是Struts2的一个插件,它提供了一种强大的布局和页面组装机制,使得开发者可以创建复杂的Web页面结构。这个压缩包文件包含了使用Struts2和Tiles框架搭建的模板源码,便于学习和参考。 在Struts2中,Tiles框架...
而Tiles是Struts2的一个重要组成部分,它允许开发者将多个页面组合成一个复杂的页面布局,实现了视图的重用和模块化。在Struts2中使用Tiles组件,可以更有效地管理和构建动态Web应用的用户界面。 首先,我们需要...
将Struts2与Tiles结合使用,可以更加灵活地管理页面结构,实现统一的页面风格,提高开发效率。 #### 二、所需JAR包 首先,为了能够成功地整合Struts2与Tiles,我们需要确保项目的类路径中包含以下JAR包: 1. **...
【描述】"没有集成struts,单纯的tiles+servlet"意味着这个例子专门关注Tiles和Servlet的整合,不涉及Struts的控制器层。Servlet是Java Web开发中的基础组件,负责处理HTTP请求并生成响应。在这个场景下,Servlet将...
Tiles2 是 Apache Struts 项目的一部分,它提供了一个模板定义语言,允许开发者定义页面布局,并通过定义好的模板来组装页面。Tiles 模板可以包含静态内容、动态内容或者其他的 Tiles 定义,这使得我们可以创建复杂...