问题
I have a requirement for formatting some variables before going to action and reformat after action executed but before rendering. I added a interceptor. I format the action variable value before invoke method called and reformat after invoke method called. Changes made before invoke method in interceptor are effective in Action execute method. But the changes made for reformat on action variables after invoke method executed are not seen when the page rendered. Will the framework not take the changes done in Action variables in interceptor's post processing section? Please help.
回答1:
By the time invoke returns control to the interceptor the result has been rendered.
You need to implement a PreResultListener as described in the big yellow box on the "Writing Interceptors" doc page.
来源:https://stackoverflow.com/questions/14697623/modified-values-for-struts-2-action-variable-in-interceptor-post-processing-not