0

How can access a public variable withouth getter and setter using OGNL in Struts2 ?

public class Keys{
    public Integer count = 1; 
    public String all_type = "ALL";
    .....
}
<s:property value="Key.all_type" />
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Ariana
  • 283
  • 1
  • 6
  • 17
  • Expose them through your action, static method access doesn't work anymore – Andrea Ligios Mar 14 '17 at 15:47
  • I import my class in the jsp `<%@ page import=" com.test.common.action.Keys, com.opensymphony.xwork2.ActionContext, java.util.*" %>` – Ariana Mar 14 '17 at 15:58
  • ...... Don't :) – Andrea Ligios Mar 14 '17 at 16:01
  • My problem is that the all_type is not a static attribute. If all_type was a static attribute I would have been able to access it using but if the attribute is not static, the sentence doesn't work. – Ariana Mar 14 '17 at 16:03
  • expose it through your action. Either make it public or use a getter, but from your action. Put it in an interface that your action implements, or in a base action that your action extends, and inherit it – Andrea Ligios Mar 14 '17 at 16:25

0 Answers0