创建自定义标签 : Struts « J2EE平台 « Java

En
Java
1. 图形用户界面
2. 三维图形动画
3. 高级图形
4. 蚂蚁编译
5. Apache类库
6. 统计图
7. 
8. 集合数据结构
9. 数据类型
10. 数据库JDBC
11. 设计模式
12. 开发相关类
13. EJB3
14. 电子邮件
15. 事件
16. 文件输入输出
17. 游戏
18. 泛型
19. GWT
20. Hibernate
21. 本地化
22. J2EE平台
23. 基于J2ME
24. JDK-6
25. JNDI的LDAP
26. JPA
27. JSP技术
28. JSTL
29. 语言基础知识
30. 网络协议
31. PDF格式RTF格式
32. 映射
33. 常规表达式
34. 脚本
35. 安全
36. Servlets
37. Spring
38. Swing组件
39. 图形用户界面
40. SWT-JFace-Eclipse
41. 线程
42. 应用程序
43. Velocity
44. Web服务SOA
45. 可扩展标记语言
Java 教程
Java » J2EE平台 » Struts屏幕截图 
创建自定义标签
创建自定义标签

/*
Title:       Struts : Essential Skills (Essential Skills)
Authors:     Steven Holzner
Publisher:   McGraw-Hill Osborne Media
ISBN:       0072256591
*/

//ch07_01.jsp

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html:html>
    <head>
        <title>Using &lt;logic&gt; Tags</title>
    </head>
    
    <body>
        <h1>Using &lt;logic&gt; Tags</h1>

        <html:form action="ch07_02.do">

            <h2>Enter your data:</h2>
            <html:text property="text"/>

            <br>
            <br>

            <html:submit value="Submit"/>
            <html:cancel/>
        </html:form>
    </body>
</html:html>

//ch07_04.jsp

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<HTML>
    <HEAD>
        <TITLE>Here's Your Data...</TITLE>
    </HEAD>
    
    <BODY>
        <H1>Here's Your Data...</H1>

        <h2>The text field text:</h2>
        <bean:write name="ch07_03" property="text"/>
        <BR>

        <h2>Using &lt;logic:empty name="ch07_03" property="empty"&gt;</h2>
        <logic:empty name="ch07_03" property="empty">
        Results: Empty
        </logic:empty>
        <BR>

        <h2>Using &lt;logic:notEmpty name="ch07_03" property="text"&gt;</h2>
        <logic:notEmpty name="ch07_03" property="text">
        Results: Not empty
        </logic:notEmpty>
        <BR>

        <h2>Using &lt;logic:equal name="ch07_03" property="number" value="6"&gt;</h2>
        <logic:equal name="ch07_03" property="number" value="6">
        Results: Equal
        </logic:equal>
        <BR>

        <h2>Using &lt;logic:notEqual&gt; name="ch07_03" property="number" value="7"</h2>
        <logic:notEqual name="ch07_03" property="number" value="7">
        Results: Not equal
        </logic:notEqual>
        <BR>

        <h2>Using &lt;logic:greaterEqual name="ch07_03" property="number" value="3"&gt;</h2>
        <logic:greaterEqual name="ch07_03" property="number" value="3">
        Results: Greater than or equal
        </logic:greaterEqual>
        <BR>

        <h2>Using &lt;logic:greaterThan name="ch07_03" property="number" value="4"&gt;</h2>
        <logic:greaterThan name="ch07_03" property="number" value="4">
        Results: Greater than
        </logic:greaterThan>
        <BR>

        <h2>Using &lt;logic:lessEqual name="ch07_03" property="number" value="8"&gt;</h2>
        <logic:lessEqual name="ch07_03" property="number" value="8">
        Results: Less than or equal
        </logic:lessEqual>
        <BR>

        <h2>Using &lt;logic:lessThan name="ch07_03" property="number" value="8"&gt;</h2>
        <logic:lessThan name="ch07_03" property="number" value="8">
        Results: Less than
        </logic:lessThan>
        <BR>

        <h2>Using &lt;logic:match name="ch07_03" property="text" value="6"&gt;</h2>
        <logic:match name="ch07_03" property="text" value="6">
        Results: Matched
        </logic:match>
        <BR>

        <h2>Using &lt;logic:notMatch name="ch07_03" property="number" value="9"&gt;</h2>
        <logic:notMatch name="ch07_03" property="number" value="9">
        Results: No match
        </logic:notMatch>
        <BR>

        <h2>Using &lt;logic:present name="ch07_03" property="number"&gt;</h2>
        <logic:present name="ch07_03" property="number">
        Results: Present
        </logic:present>
        <BR>

        <h2>Using &lt;logic:notPresent name="ch07_03" property="fish"&gt;</h2>
        <logic:notPresent name="ch07_03" property="fish">
        Results: Not present
        </logic:notPresent>
        <BR>

    </BODY>
</HTML>

//ch07_05.jsp
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<html:html>
    <head>
        <title>Using &lt;bean&gt; Tags</title>
    </head>

    <body
        <h1>Using &lt;bean&gt; Tags</h1>
  
        <%
        Cookie cookie1 = new Cookie("message""Hello!");
        cookie1.setMaxAge(24 60 60);
        response.addCookie(cookie1)
        %> 
    
        <html:form action="ch07_06.do">

            <h2>Enter your data:</h2>
            <html:text property="text"/>

            <br>
            <br>

            <html:submit value="Submit"/>
            <html:cancel/>
        </html:form>
    </body>
</html:html>

//ch07_08.jsp
<%@ page import="ch07.ch07_07" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<HTML>
    <HEAD>
        <TITLE>Here's Your Data...</TITLE>
    </HEAD>
    
    <BODY>
        <H1>Here's Your Data...</H1>

        <h2>The text field text:</h2>
        <bean:write name="ch07_07" property="text"/>
        <BR>

        <h2>The cookie data:</h2>
        <bean:cookie id="messageCookie" name="message"/>
        <%= messageCookie.getValue() %>
        <BR>

        <h2>The new variable:</h2>
        <bean:define id="variable" name="ch07_07" property="text"/>
        <%= variable %>
        <BR>

        <h2>The user-agent header data:</h2>
        <bean:header id="headerObject" name="user-agent"/>
        <%= headerObject %>
        <BR>

        <h2>The parameter data:</h2>
        <bean:parameter id="text" name="text"/>
        <%= text %>
        <BR>

        <h2>The mapping data:</h2>
        <bean:struts id="mapping" mapping="/ch07_06"/>
        <% String[] a = mapping.findForwards()
        out.println(a[0]); %>
        <BR>

    </BODY>
</html>

package ch07;

import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ch07_03 extends ActionForm 
{
    
    private String empty = "";
    private String text = "";
    private int number;
    
    public String getEmpty() 
    {
        return empty;
    }
    
    public void setEmpty(String text
    {
    }
    
    public String getText() 
    {
        return text;
    }
    
    public void setText(String text
    {
        this.text = text;
        this.number = Integer.parseInt(text);
    }
    
    public int getNumber() 
    {
        return number;
    }
    
    public void setNumber(int number
    {
        this.number = number;
    }
    
}

package ch07;

import java.io.*;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import org.apache.struts.action.*;

public class ch07_06 extends Action 
{
  public ActionForward execute(ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {

        return mapping.findForward("success");
    }
}

package ch07;

import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ch07_07 extends ActionForm 
{
    
    private String text = "";
    
    public String getText() 
    {
        return text;
    }
    
    public void setText(String text
    {
        this.text = text;
    }
    
}

package ch07;

import java.io.*;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import org.apache.struts.action.*;

public class ch07_02 extends Action 
{
  public ActionForward execute(ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {

        return mapping.findForward("success");
    }
}

           
       
Struts-Essential-Skills-ch07.zip( 1,456 k)
Related examples in the same category
1. 练习1 :建立你的第一个Struts的应用练习1 :建立你的第一个Struts的应用
2. Exercise 2: Improving your first Struts Application Exercise 2: Improving your first Struts Application
3. 练习3 :使用JSTL , Struts的EL练习3 :使用JSTL , Struts的EL
4. Struts 方法: Struts的构建与蚂蚁编译
5. Using bean:resource to expose the struts.config.xml to your view
6. Create a pluggable validator for cross-form validation 2Create a pluggable validator for cross-form validation 2
7. Struts: Generate a response with XSL
8.  Hibernate and Struts  Hibernate and Struts
9.  In-container testing with StrutsTestCase and Cactus
10. Exercise 4: Applying Gof and J2EE Patterns:Deploy to WebLogic and Test
11. Exercise 5: Search, List, Action Chaining, Editable List Form
12. Exercise 6: Paging
13. Exercise 7: Better Form and Action Handling
14. 练习8 :创建Struts的模块
15. Exercise 9: Using Commons Validator with Struts
16. Exercise 10: Using Struts and Tiles
17. Struts的基础事件Struts的基础事件
18. 完整的Struts应用完整的Struts应用
19. Struts的创建视图Struts的创建视图
20. Struts的:创建示范Struts的:创建示范
21. Struts的:创建控制器Struts的:创建控制器
22. Struts标签Struts标签
23. Struts和标签Struts和标签
24. Web服务,验证和瓷砖套餐Web服务,验证和瓷砖套餐
25. Struts框架: Struts的应用实例Struts框架: Struts的应用实例
26. Struts框架验证
27. Struts框架:瓷砖Struts框架:瓷砖
28. Struts框架:声明异常处理
29. Struts的:Struts的国际化应用
30. Struts的安全应用
31. Struts的应用测试
32. Struts的例子Struts的例子
33. Struts的空白模板Struts的空白模板
34. Struts框架
35. Struts的:银行的应用
36. Struts的应用Struts的应用
37. Struts的应用2Struts的应用2
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.