zoukankan      html  css  js  c++  java
  • struts1

    <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
    <%@page import="com.jyc.damain.Cat"%>
    <%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>

    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>

    </head>

    <body>
    <h3>bean tags</h3>
    <%
    request.setAttribute("a","ok");

    Cat c = new Cat();
    c.setName1("tom");
    c.setAge("1");
    //c.setCount(1);
    request.setAttribute("cat",c);
    %>

    <!-- bean:write 用于输出信息 -->
    <bean:write name="a"/><br/>

    <bean:define id="kk" name="a" value="hello" ></bean:define>
    <bean:write name="a"/>
    <h3> get对象</h3>
    <bean:write name="cat" property="name1"/>
    <bean:write name="cat" property="age"/><br>
    <h3>bean:message</h3>


    </body>
    </html>

    ---------------

    <body>
    <%
    int i = 2;
    Cat c = new Cat();
    c.setAge("1");
    c.setName1("c1");
    Cat c2 = new Cat();
    c2.setAge("2");
    c2.setName1("c2");
    Cat c3 = new Cat();
    c3.setAge("3");
    c3.setName1("c3");
    ArrayList<Cat> al= new ArrayList<Cat>();
    al.add(c);
    al.add(c2);
    al.add(c3);

    request.setAttribute("num",i);
    request.setAttribute("cats",al);
    %>

    <logic:notEmpty name="cats">
    <logic:iterate id="mycat" name="cats">

    <bean:write name="mycat" property="name1"/>=
    <bean:write name="mycat" property="age"/><br/>

    ${mycat.name1 } == ${mycat.age }
    cats is not null<br/>
    </logic:iterate>
    </logic:notEmpty>

    <br/>

    <h3>logic compare big or small</h3>

    <logic:iterate id="cc" name="cats" >
    <logic:greaterThan name="cc" value="${num }" property="age">
    <bean:write name="cc" property="name1"/> dayu ${num }<br/>
    </logic:greaterThan><br/>
    <logic:equal value="${num }" name="cc" property="age">
    <%--name="对象名称" property="属性名称" value="比较值" --%>
    等于${num }的猫是:<bean:write name="cc" property="name1"/><br/>
    </logic:equal>
    </logic:iterate><br/>

    <logic:empty name="ee">ee is null</logic:empty><br/>
    i的值:${num }<br/>

    <h3></h3>
    <logic:match value="" ></logic:match>
    </body>

    ---------------

    <body>
    <h3>logic2.jsp</h3>
    <%
    HashMap course = new HashMap();
    course.put("math",new Integer(120));
    course.put("english",new Integer(122));
    course.put("chinese",new Integer(100));
    course.put("physics",new Integer(111));
    course.put("chymistry",new Integer(129));
    course.put("biology",new Integer(111));
    course.put("politics",new Integer(98));
    course.put("geography",new Integer(132));
    course.put("history",new Integer(98));
    request.setAttribute("course",course);
    %>
    <bean:size id="course_length" name="course"/>
    <%=course_length.toString()%><br>
    <logic:present name="course">
    <logic:iterate id="c" name="course" length="<%=course_length.toString()%>" offset="3" indexId="course_id">


    <bean:write name="c" property="key"/>:<br>

    </logic:iterate>
    </logic:present>

    <h3></h3>

    </body>

    public class Cat {

    private String name;
    private String age;
    /**
    * @return the name
    */
    public String getName1() {
    return name;
    }
    /**
    * @param name the name to set
    */
    public void setName1(String name) {
    this.name = name;
    }
    /**
    * @return the age
    */
    public String getAge() {
    return age;
    }
    /**
    * @param age the age to set
    */
    public void setAge(String age) {
    this.age = age;
    }
    }

  • 相关阅读:
    vs.net 2005 C# WinForm GroupBOX 的BUG?尝试读取或写入受保护的内存。这通常指示其他内存已损坏
    Git安装及基本使用
    c++实现将表达式转换为逆波兰表达式
    2015年倒数第6周学习报告
    读过的书及读后感
    c++实现队列
    链表插入排序(insertion-sort-list)
    test
    [转]maven入门
    几个学习Maven不错的网址
  • 原文地址:https://www.cnblogs.com/qq3245792286/p/6270503.html
Copyright © 2011-2022 走看看