Samuel Learning

  • 联系
  •  
  • 管理

文章分类(203)

  • 01 ASP/HTML(6)
  • 02 Script/CSS(16)
  • 03 C/C++
  • 04 XML(4)
  • 05 微软编程(26)
  • 06 J2EE(60)
  • 09 Linux(14)
  • 10 Database(27)
  • 11 报表打印
  • 12 打包安装(1)
  • 13 模式重构(2)
  • 14 系统架构
  • 15 敏捷开发(11)
  • 16 案例分析(30)
  • 17 Workflow(1)
  • 18 配置管理(1)
  • 19 项目管理
  • 20 英语(4)

新闻分类(52)

  • CXF学习
  • Hibernate学习(1)
  • iBatis学习(16)
  • Struts1学习(1)
  • Struts2学习(34)

.NET资源

  • adxmenu
  • C# Open Source
  • DNN Directory
  • M2Land
  • Windows Form FAQ
  • 中国DNN
  • 中国DNN联盟

Ajax

  • DoJo
  • GWT
  • JQuery
  • jquery autocomplete
  • jquery flexgrid
  • JQuery Form
  • jquery masked input
  • JQuery UI
  • jquery validation
  • Jquery 图表
  • jquery报表
  • jquery插件集合
  • Qooxdoo
  • Tibco GI
  • YUI
  • YUI-EXT
  • ZeroKode

Java开源

  • ABLE
  • Agile Tao
  • Ajax4JSF
  • Alfresco
  • AppFuse
  • Compiere
  • Equinox
  • Findbugs
  • Geronimo
  • Grails
  • Harmony
  • Hibernate论坛
  • JAG
  • Java开源大全
  • Java视线论坛
  • jBPM工作流
  • JSFTutorials
  • Nereide ERP
  • Ofbiz ERP
  • Opentaps ERP
  • operamasks
  • Petstore
  • Prototype.js
  • RIFE
  • Runa
  • SpringSide
  • Struts Menu
  • Sun Glassfish
  • Trails
  • YUI4JSF
  • 满江红

Mobile

  • Sencha

WEB资源

  • DHTML中心
  • DHTML参考手册
  • DHTML文档
  • EclipsePlugin
  • Firebug
  • GRO Clinux
  • jMaki
  • JSTL文档
  • LoadIcon
  • Openlaszlo
  • Struts Menu 展示
  • Web Test Tools
  • WebCtrs
  • Webdeveloper
  • 中国RIA开发者论坛

Workflow

  • E-Workflow
  • JBPM
  • OpenWFE
  • OSWorkflow
  • WFMC
  • Workflow Research

其他连接

  • confach
  • CPP
  • ejay
  • Giovanni
  • 丹佛
  • 交大e-learning
  • 交大研究生院
  • 可恶的猫
  • 天天@blog
  • 我的相册
  • 阿飞

大牛人

  • 32篇JBPM
  • David.Turing
  • HongSoft@业务集成
  • Joel
  • Koen Aers
  • Martinfowler
  • Raible Matt
  • Raible Wiki
  • Scott W.Ambler
  • Tom Baeyens
  • Uncle Bob
  • 一个世界在等待
  • 子在川上曰
  • 小布老师
  • 小明
  • 差沙
  • 徐昊
  • 江南白衣
  • 汪博士
  • 汪小金
  • 银狐999

开源软件

  • 2Bizbox ERP
  • CompiereCRM&ERP
  • EGW
  • Vtiger CRM
  • webERP

敏捷

  • Canoo
  • Cruisecontrol
  • DBUnit
  • EL4Ant
  • Extreme Programming
  • Fit
  • Fitnesse
  • JFrog
  • Liquibase
  • Maven
  • MockObjects
  • Selenium
  • Squish
  • xpairtise
  • XPlanner
  • XProgramming
  • 敏捷联盟

数据库

  • Oracle 中国
  • Oracle-ERP
  • Oracle在线社区

未归类

  • Aquarius Orm Studio
  • mambo建站系统
  • Oracle产品下载
  • 远程同步管理工具Capivara

经典框架

  • Apache Shale
  • formdef-struts
  • FreeMarker 主页
  • JBoss Seam
  • JSF 中心
  • JSF 入门应用
  • JSF中国
  • MyFaces官方
  • Spring 社区
  • Spring专业网站
  • Spring中文论坛
  • Spring参考手册
  • Spring官方网站
  • strecks-struts
  • Struts1
  • Struts2
  • Struts-layout
  • StrutsWiKi
  • Tapestry WIKI
  • Tapestry 官方
  • Tapestry4开发指南
  • Tapestry中文文档
  • Webwork2文档
  • Wicket

网络教程

  • Laliluna
  • RoseIndia
  • Sang Shin
  • Visualbuilder

著名站点

  • Buildix
  • Dev2Dev
  • IBM dev中国
  • InfoQ
  • ITPub
  • Java Eye
  • Java Research
  • JavaRead
  • JavaWorldTW
  • Matrix
  • PHP100
  • PHPX
  • SpringSideWiKi
  • TheServerSide
  • TWPHP
  • 中国工作流论坛

项目管理

  • 管理人网

最新评论

View Post

Cookbook-struts1.3.8案例分析-Logic Tags

 

Cookbook-struts1.3.8案例分析-Logic Tags

l Logic Tags

入口Action配置

<action path="/prepareLogic"

           type="examples.logic.PrepareLogicAction">

           <forward name="success" path="/jsp/logic/Logic.jsp" />

</action>

SuccessAction,继承自Action,execute方法如下

public ActionForward execute(

        ActionMapping mapping,

        ActionForm form,

        HttpServletRequest request,

        HttpServletResponse response)

        throws Exception {

        //往Request范围内放置一些变量

        TestBean bean = new TestBean();

        request.setAttribute("testBean", bean);

        ArrayList items = new ArrayList();

        request.setAttribute("items", items);

        request.setAttribute("intValue", new Integer(7));

        request.setAttribute("stringValue", "Hello, world!");

        /* Collection of custom beans */

        ArrayList books = new ArrayList();

        books.add(new BookBean("0596003285", "Programming Jakarta Struts"));

        books.add(new BookBean("1930110502", "Struts in Action"));

        books.add(new BookBean("1861007817", "Professional Struts Applications"));

        books.add(new BookBean("0672324725", "Struts Kick Start"));

        books.add(new BookBean("0471213020", "Mastering Jakarta Struts"));

        books.add(new BookBean("1558608621", "The Struts Framework"));

        books.add(new BookBean("0971661901", "Struts Fast Track"));

        request.setAttribute("books", books);

        ActionErrors errors = new ActionErrors();

        errors.add(ActionMessages.GLOBAL_MESSAGE,

            new ActionMessage("errors.detail", "This is a global error #1"));

        errors.add(ActionMessages.GLOBAL_MESSAGE,

            new ActionMessage("errors.detail", "This is a global error #2"));

        errors.add("test",

            new ActionMessage("errors.detail", "This is a test error"));

        ActionMessages messages = new ActionMessages();

        messages.add(ActionMessages.GLOBAL_MESSAGE,

            new ActionMessage("message.detail", "This is global message #1"));

        messages.add(ActionMessages.GLOBAL_MESSAGE,

            new ActionMessage("message.detail", "This is global message #2"));

        messages.add("test",

            new ActionMessage("message.example.simple"));

        //设置Message和Error

        saveMessages(request, messages);

        saveErrors(request, errors);

        // Forward to the form

        return mapping.findForward("success");

}

JSP文件对Bean标签的处理

对cookie的判断,显示与否

<logic:present cookie="JSESSIONID">

    <p>Session cookie is present.</p>

</logic:present>

<logic:notPresent cookie="UNKNOWN">

    <p>UNKNOWN cookie is not present.</p>

</logic:notPresent>

参数判断,显示与否

<logic:present parameter="param">

    <bean:parameter name="param" id="test"/>

    <p><bean:write name="test"/></p>

</logic:present>

<logic:notPresent parameter="param">

    <p>Parameter 'param' not present.

    <html:link action="/prepareLogic?param=The parameter is present">

        Redisplay page with parameter present.

     </html:link>

    </p>

</logic:notPresent>

Request范围内存在判断,显示与否

<h3>Bean</h3>

<logic:present name="testBean">

    <p>'testBean' is present.</p>

</logic:present>

<logic:notPresent name="anotherTestBean">

    <p>'anotherTestBean' is not present.</p>

</logic:notPresent>

上下文变量的属性存在判断,显示与否

<logic:present name="testBean" property="fred">

    <p>'fred' property is present on 'testBean'</p>

</logic:present>

<logic:notPresent name="testBean" property="fred">

    <p>'fred' property is not present on 'testBean'</p>

</logic:notPresent>

<logic:present name="testBean" property="stringValue">

    <p>'stringValue' property is present on 'testBean'</p>

</logic:present>

集合是否为空判断,是否显示

<logic:present name="items">

    <p>'items' was found.</p>

</logic:present>

<logic:empty name="items">

    <p>'items' is empty</p>

</logic:empty>

<logic:notEmpty name="items">

    <p>'items' is not empty</p>

<%--   <bean:size collection="items" id="itemsSize"/>

    <p>Items has <bean:write name="itemsSize" /> items.</p>

--%>  

</logic:notEmpty>

大小比较

<logic:equal name="intValue" value="7">

    <p>intValue == 7</p>

</logic:equal>

<logic:greaterEqual name="intValue" value="7">

    <p>intValue &gt;= 7</p>

</logic:greaterEqual>

<logic:greaterEqual name="intValue" value="6">

    <p>intValue &gt;= 6</p>

</logic:greaterEqual>

<logic:greaterThan name="intValue" value="6">

    <p>intValue &gt; 6</p>

</logic:greaterThan>

<logic:lessEqual name="intValue" value="7">

    <p>intValue &lt;= 7</p>

</logic:lessEqual>

<logic:lessEqual name="intValue" value="8">

    <p>intValue &lt;= 8</p>

</logic:lessEqual>

<logic:lessThan name="intValue" value="8">

    <p>intValue &lt; 8</p>

</logic:lessThan>

模糊匹配

<logic:match name="stringValue" value="world">

    <p>stringValue matches 'world'</p>

</logic:match>

<logic:notMatch name="stringValue" value="earth">

    <p>stringValue does not match 'earth'</p>

</logic:notMatch>

<logic:notMatch name="stringValue" value="world">

    <p>stringValue does not match 'world'</p>

</logic:notMatch>

迭代集合

<logic:iterate name="books" id="book" indexId="index">

    <li><bean:write name="book" property="title"/></li>

</logic:iterate>

<logic:iterate name="books" id="book" offset="2" length="3">

    <li><bean:write name="book" property="title"/></li>

</logic:iterate>

显示错误集合

<logic:messagesPresent>

<p>Global errors:</p>

<ul>

 <html:messages id="error" property="<%=ActionErrors.GLOBAL_MESSAGE%>">

 <li><bean:write name="error"/></li>

 </html:messages>

</ul>

<p>Errors for 'test':</p>

<ul>

 <html:messages id="error" property="test">

 <li><bean:write name="error"/></li>

 </html:messages>

</ul>

</logic:messagesPresent>

<logic:messagesNotPresent>

    <p>There are no errors</p>

</logic:messagesNotPresent>

显示消息

<logic:messagesPresent message="true">

 <ul>

 <html:messages id="msg" message="true" property="<%=ActionMessages.GLOBAL_MESSAGE%>">

 <li><bean:write name="msg"/></li>

 </html:messages>

 </ul>

<p>Messages for 'test':</p>

<ul>

 <html:messages id="msg" property="test" message="true">

 <li><bean:write name="msg"/></li>

 </html:messages>

</ul>

</logic:messagesPresent>

<logic:messagesNotPresent message="true">

    <p>There are no messages</p>

</logic:messagesNotPresent>

posted on 2008-07-08 02:19 MingIsMe 阅读(160) 评论(0)  编辑  收藏 所属分类: 16 案例分析

 
Powered by:
BlogJava
Copyright © MingIsMe