日期:2014-05-20  浏览次数:20901 次

我想从静态类中复制给<s:select list
以前看见有人写过<s:select list='@com.test.PubUtil@getPapList("cardType")' name="cardType" listKey="pap_value" listValue="pap_value">
注:com.test.PubUtil.getPapList是个静态方法,


但是我今天这么写(<s:select list='#com.citic.util.PubUtils@getParaList("cardType")' name="documentType1" listKey="PAP_VALUE" listValue="PAP_SHOWCN"> </s:select>)却报了一个错如下(注:这个方法在页面中使用<%=com.citic.util.PubUtils.getParaList("cardType").size()%>取出的list的size确实有值):


org.apache.jasper.JasperException: tag 'select', field 'list', name 'memberInfo.ctfType': The requested list key '@com.citic.util.PubUtils@getParaList("cardType")' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)



------解决方案--------------------
在struts.properties里面添加:struts.ognl.allowStaticMethodAccess=true,搞定,从此可以自由访问静态方法