zoukankan      html  css  js  c++  java
  • OGNL相关代码

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    
    <%
    application.setAttribute("app", "application的内容");
    session.setAttribute("ses", "会话的测试");    
    request.setAttribute("req", "request的内容");
    
    application.setAttribute("ses", "123123");
    session.setAttribute("app", "会话的测12313试");    
    
    %>
    <a href=""></a>
    
    <a href="test?userID=9999&date=123">下一个页面</a>
    
    
    <a href="testtag?userID=aaaaa">下一个页面</a>
    
    </body>
    </html>
    <%@page import="java.util.Date"%>
    <%@page import="com.opensymphony.xwork2.util.ValueStack"%>
    <%@page import="com.opensymphony.xwork2.ActionContext"%>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
        
    <%@ taglib prefix="s"  uri="/struts-tags"%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    
    <%
    ActionContext ac = ActionContext.getContext();
    
    ValueStack vs = ac.getValueStack();
    
    //弹出顶部的对象
    //Date dt = (Date)vs.pop();
    
    
    //得到顶部对象
    //Date dt = (Date)vs.peek();
    //out.print(dt);
    
    %>
    
    使用OGNL访问值栈
    <br><br>
    
    EL方式
    ${date }<br>
    ${userID }
    <br>
    访问map栈
    ${sessionScope.ses }
    
    
    
    <br>
    标签方式
    <s:property value='[1]["date"]'/>
    <s:property value= "userID"/>
    <br>
    <s:property value="[1].date"/>
    <br>
    
    <s:property value="[0].userID"/>
    
    <br>
    输出顶部对象
    <s:property/>
    
    <br>
    访问map栈
    <s:property  value="#session.ses"/>
    <br>
    <s:property value="#parameters.userID"/>
    <br>
    <s:property value= "#application.app"/>
    <br>
    <s:property value= "#request.req"/>
    <br>
    <s:property value= "#attr.ses"/>
    
    
    <br>
    调用实例方法:
    产生随机数=<s:property value="[0].nextInt(100)"/>
    
    <br>
    调用静态属性和静态方法:
    随机数=<s:property value="@java.lang.Math@random()"/>
    <br>
    PI=<s:property value="@java.lang.Math@PI"/>
    <br>
    
    访问List类型的对象
    <br>
    List的长度=<s:property value="[0].size()"/>
    <br>
    <s:property value="[0].get(0)"/>
    
    
    <br><br>
    访问对象的集合属性
    长度=<s:property  value="[0].myList.size()"/>
    <br>
    内容=<s:property value= "[0].myList[]"/>
    <br>
    内容0=<s:property value= "[0].myList[0]"/>
    <br>
    是否为空=<s:property value="[0].myList.isEmpty"/>
    
    
    
    <!-- 打印到界面 -->
    <s:debug></s:debug>
    
    
    
    
    </body>
    </html>
  • 相关阅读:
    轻松学习Linux之AWK使用初步
    轻松学习Linux之理解Shell的硬链接与软连接
    轻松学习Linux之自动执行任务
    轻松学习Linux系统安装篇之fdisk命令行工具的使用
    Leetcode-1030 Next Greater Node In Linked List(链表中的下一个更大节点)
    Leetcode-1028 Convert to Base -2(负二进制转换)
    Leetcode-1029 Binary Prefix Divisible By 5(可被 5 整除的二进制前缀)
    ACM模板——2的次方表
    ACM模板——快速幂
    ACM模板——素数相关
  • 原文地址:https://www.cnblogs.com/zs6666/p/6108506.html
Copyright © 2011-2022 走看看