I have an interceptor that needs to abort an action and redirect to a new page. Currently, it’s returning a string like “go_to_foo”. That’s working fine, but I also want to send an additional parameter to the action. I’ve tried to configure that result in struts.xml like:
<global-results>
...
<result name="go_to_foo">
<param name="location">foo.jsp</param>
<param name="testing">mark</param>
</result>
</global-results>
I’m getting the following exception: Caught OgnlException while setting property ‘testing’ on type ‘org.apache.struts2.dispatcher.ServletDispatcherResult’. I’m wondering if this is due to the fact that the Request object doesn’t know about any ‘testing’ parameter.
Alternatively, I’m also wondering if it’s possible for an Interceptor to add/modify the request’s parameters before returning the string “go_to_foo” such that they are still available in foo.jsp. If something like this is possible perhaps I don’t need what’s above.
I hope that was clear enough.
Thanks,
Mark
The
<param/>tag is for setting parameters on the result, not for adding query string parameters to the redirect.e.g.,
<param name="testing">mark</param>is trying to callsetTesting("mark")on the ServletRedirectResult class. There is no such method.Try:
<param name="location">foo.jsp?testing=mark</param>Also, do you really need to redirect? Why not just add the needed parameter to the action context and continue on?