---
title: "Struts2标签中访问静态变量或者方法"
author: "wmj2003"
date: "2009-04-17T11:32:00Z"
tags: []
slug: "struts2"
draft: false
lastmod: "2009-04-17T11:32:00Z"
id: 379448
url: "https://wmj2003.iteye.com/blog/379448"
---

# Struts2标签中访问静态变量或者方法

在2.1.2中，如果要通过ognl访问静态方法，必须在struts.properties或者struts.xml中将选项struts.ognl.allowStaticMethodAccess设置为true.

&lt;s:propteryvalue="@com.work.core.QxglConstants@TOP\_LEVEL\_TOP"/&gt;

&lt;s:if[test="#session.deptid==@com.work.core.QxglConstants@TOP\_LEVEL\_DEPT\_ID"&gt;复检受理&lt;/s:if&gt;](mailto:test=%3E%E5%A4%8D%E6%A3%80%E5%8F%97%E7%90%86%3C/s:if%3E)

注意：访问的类名必须是全称。是@com.work.core.QxglConstants而不是@QxglConstants

&lt;!--EndFragment--&gt;