1

I've my Struts 2 actions as ModelDriven. I've some fields defined on the actions themselves as well. However, if in the JSP I use wrong field names that are neither in ModelDriven model nor directly used as action member fields then I don't get any errors and it simply ignores those fields.

 <s:if test="(method == 'list')">

If method is neither a ModelDriven model field nor an action member field then it simply ignores this s:if statement and doesn't execute instructions inside this s:if statement.
Any idea on how to throw errors on JSP for fields that are non-mapped in the ModelDriven models fields or in the actions of ModelDriven models?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Shah-G
  • 652
  • 1
  • 8
  • 22

1 Answers1

1

OGNL expressions can throw exceptions but they are caught internally.

The OGNL expression is evaluated in this attribute, like in many other attributes of Struts tags, and if can't resolve the value it returns null. This value is unacceptable for the if tag.

However, if you know which expression returns null then create a boolean expression.


Any idea on how to throw errors on jsp...

The java code is encapsulated in the tags implementation. If tags cannot execute they throw 500 internal server error. You can write your custom tags to throw that errors.

Roman C
  • 49,761
  • 33
  • 66
  • 176