<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ 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>OGNL</title>
</head>
<body>
<s:debug></s:debug>
productName:${productName}
<br><br>
productName:^<s:property value="[1].productName"/>
<br><br>
productDesc:${productDesc }
<br><br>
<!-- productPrice:${productPrice}
<br><br>
-->
productPrice:<s:property value="[0].productPrice"/>
<br><br>
productName1:${sessionScope.product.productName}
<s:property value="#session.product.productName"/>
<br><br>
productName2:${requestScope.test.productName}
<s:property value="#request.test.productName"/>
<br><br>
<!-- 使用 OGNL 调用public 类的public类型的静态字段和静态方法-->
<s:property value="@java.lang.Math@PI"/>
<br><br>
<s:property value="@java.lang.Math@cos(0)"/>
<!-- 调用对象栈的方法为一个属性赋值 -->
<br><br>
<s:property value="setProductName('SB')"/>
<s:property value="productName"/>
<br><br>
<!-- 调用数组对象的属性 -->
<%
String [] names = new String[]{"aa","bb","cc"};
//把值放入到request中
request.setAttribute("names", names);
%>
length<s:property value="#attr.names.length"/>
<br><br>
names[2]:<s:property value="#attr.names[1]"/>
<!-- Map的调用 -->
<%
Map<String,String> letts = new HashMap<String,String>();
request.setAttribute("lettr", letts);
letts.put("AAA", "111");
letts.put("BBB", "222");
letts.put("CCC", "333");
%>
<br><br>
<s:property value="#attr.lettr.size"/>
<br><br>
AAA:<s:property value="#attr.lettr['AAA']"/>
</body>
</html>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ 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>OGNL</title>
</head>
<body>
<s:debug></s:debug>
productName:${productName}
<br><br>
productName:^<s:property value="[1].productName"/>
<br><br>
productDesc:${productDesc }
<br><br>
<!-- productPrice:${productPrice}
<br><br>
-->
productPrice:<s:property value="[0].productPrice"/>
<br><br>
productName1:${sessionScope.product.productName}
<s:property value="#session.product.productName"/>
<br><br>
productName2:${requestScope.test.productName}
<s:property value="#request.test.productName"/>
<br><br>
<!-- 使用 OGNL 调用public 类的public类型的静态字段和静态方法-->
<s:property value="@java.lang.Math@PI"/>
<br><br>
<s:property value="@java.lang.Math@cos(0)"/>
<!-- 调用对象栈的方法为一个属性赋值 -->
<br><br>
<s:property value="setProductName('SB')"/>
<s:property value="productName"/>
<br><br>
<!-- 调用数组对象的属性 -->
<%
String [] names = new String[]{"aa","bb","cc"};
//把值放入到request中
request.setAttribute("names", names);
%>
length<s:property value="#attr.names.length"/>
<br><br>
names[2]:<s:property value="#attr.names[1]"/>
<!-- Map的调用 -->
<%
Map<String,String> letts = new HashMap<String,String>();
request.setAttribute("lettr", letts);
letts.put("AAA", "111");
letts.put("BBB", "222");
letts.put("CCC", "333");
%>
<br><br>
<s:property value="#attr.lettr.size"/>
<br><br>
AAA:<s:property value="#attr.lettr['AAA']"/>
</body>
</html>