===============================================================================
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'testognl1.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<%--
request.setAttribute("age",10);
session.setAttribute("username","yhdata");
application.setAttribute("count",5);
--%>
<s:set name="age" value="10" scope="request"/>
<s:set name="username" value="'yhdata'" scope="session"/>
<s:set name="count" value="5" scope="application"/>
<s:set name="count" value="15" scope="request"/>
#request.age:<s:property value="#request.age"/><br/>
#session.username:<s:property value="#session.username"/><br/>
#application.count:<s:property value="#application.count"/><br/>
#attr.count:<s:property value="#attr.count" /><br />
<h1><s:property value="#attr.age"/></h1>
======================================<br>
<s:set name="China" value="'c'"/>
<s:set name="country1" value="China"/>
<s:set name="country2" value="'China'" />
#country1:<s:property value="#country1"/><br/>
#country2:<s:property value="#country2"/><br/>
#request.country2:<s:property value="#request.country2"/><br/>
<s:debug></s:debug>
</body>
</html>
===============================================================================
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'testogn2.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<s:set name="myurl" value="'index.jsp'"/>
1:<s:url value="#myurl" /> <br>
2:<s:url value="%{#myurl}"/><br><!-- %{}作用:告诉编译器 里面内容ognl表达式 -->
===========================<br/>
3:<s:property value="#myurl"/><br/>
4:<s:property value="%{#myurl}"/><br>
===========================<br/>
5:<s:url value="https://www.baidu.com/"/><br>
6:<s:url value="'https://www.baidu.com/'"/><br>
<s:url value="%{#myurl}" id="url">
<s:param name="i" value="8"></s:param>
</s:url>
<s:a href="%{#url}">xxxx</s:a>
<s:debug></s:debug>
</body>
</html>
===============================================================================
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'testognl3.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<s:set name="list" value="{'UI','JAVA','PHP'} " />
#list[0]:<s:property value="#list[0]" /><br />
#list[2]:<s:property value="#list[2]" /><br />
#list.size:<s:property value="#list.size" /><br />
list-iterator:
<s:iterator value="#list" var="v">
<s:property value="#v"/>
</s:iterator>
<br/>==================================<br>
<s:set name="array" value="new int[]{1,2,3,4}" />
#array[0]:<s:property value="#array[0]" /><br />
#array[2]:<s:property value="#array[2]" /><br />
#array.length:<s:property value="#array.length" /><br />
array-iterator:
<s:iterator value="#array">
<s:property />
</s:iterator>
<br/>==================================<br>
<s:set name="map"
value="#{'cn':'China','us':'the United States','fr':'France'}"/>
#map['cn']:<s:property value="#map['cn']" /><br />
#map.cn:<s:property value="#map.cn" /><br />
map-iterator:
<s:iterator value="#map">
<s:property value="key" />---<s:property value="value" />,
</s:iterator>
<s:debug></s:debug>
</body>
</html>
===============================================================================
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'testognl4.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
用户名:<s:property value="user.name"/><br>
用户名:<s:property value="user.name.toUpperCase()"/><br>
年龄:<s:property value="user.age"/><br>
国家:<s:property value="user.address.country"/><br>
<s:debug></s:debug>
</body>
</html>