Using OGNL to access Static Methods in Struts 2
One of my favorite things that OGNL can do in WebWorks and Struts 2 is call any static method using the OGNL scripting language. You can do this by using the notation
@classname@methodname(arg) This in the past has worked great for me, but when you are using Struts 2.1.x there is a new properties value that needs to be added to your struts.properties file. Add the following line:struts.ognl.allowStaticMethodAccess=trueThis value is set to false by default, so you are not able to access static methods. Since I was not aware of this, I wasted about a hour trying to hunt down why the method was never being called.
The good thing is that you can still access static constants using OGNL by calling
@classname@CONSTANTFor more info on this change check out JIRA WW-2160



