« Return to Thread: How can I tell Struts 2 to throw/log exceptions for invalid OGNL Expressions
Is it possible to use altSyntax to solve this problem? In other words, require %{} around all expressions? Looking through the docs, it doesn't seem like altSyntax is supported in Struts 2.
https://issues.apache.org/struts/browse/WW-1819
Thanks,
Mattmraible wrote:I'll take that as a "no", it is not possible to get better error messages. That's too bad since it seems I get better type-safety and errors from scriptlets instead of OGNL.mraible wrote:I have the following class:
public class TestAction {
public static String concat(String str1, String str2) {
return str1 + " and " + str2;
}
}
In a JSP, I can write the following and it works fine:
<s:property value="@org.appfuse.web.TestAction@concat('1', '2')"/>
However, if I change it to an invalid class name, it fails silently:
<s:property value="@org.appfuse.web.InvalidClass@concat('1', '2')"/>
I've tried turning up the logging for org.apache.struts2, com.opensymphony.xwork2 and ognl - but it still fails silently. Any ideas how to get better error messages about invalid OGNL expressions?
<%@ page import="org.foo.bar.baz.SettingsServlet,org.foo.bar.baz.enums.EnumCodec" %>
<c:set var="q"><%=EnumCodec.URL.encode(SettingsServlet.ACTIONS.networkUpdates)%></c:set>
<s:property value="url(@vs@SETTINGS_SERVLET).q('${q}')"/>
VS:
<s:property value="url(@vs@SETTINGS_SERVLET).q(@org.foo.bar.baz.enums.EnumCodec@URL.encode(@org.foo.bar.baz.SettingsServlet$ACTIONS@networkUpdates))"/>
The framework I'm looking to migrate to Struts 2 has the ability for it's EL to read from imported Statics - a pretty cool feature IMO.
${url(pageBean.MAPPING.SETTINGS_SERVLET).q(EnumCodec.URL.encode(SettingsServlet.ACTIONS.networkUpdates))}
Matt
« Return to Thread: How can I tell Struts 2 to throw/log exceptions for invalid OGNL Expressions
| Free embeddable forum powered by Nabble | Forum Help |