一 配置文件
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="GBK"/>
<!-- 设置允许OGNL允许访问静态方法 -->
<constant name="struts.ognl.allowStaticMethodAccess"
value="true"/>
<package name="lee" extends="struts-default">
<action name="*">
<result>/WEB-INF/content/{1}.jsp</result>
</action>
</package>
</struts>
二 测试页面
<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>使用Struts 2标签访问静态成员和静态方法</title>
<meta name="website" content="http://www.crazyit.org" />
</head>
<body>
<s:debug/>
访问系统环境变量:<s:property value=
"@java.lang.System@getenv('path')"/> <br />
圆周率的值:<s:property value="@java.lang.Math@PI"/>
</body>
</html>
三 测试结果