I want to apply logging advice to Struts Action classes. Specifically I want to apply logging when the Struts Action class throws an exception.
I have integrated the Struts with Spring using the ContextLoaderPlugin in the struts-config.xml as :
<plug-in
className="org.springframework.web.struts.ContextL oaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/spring-test.xml"/>
</plug-in>
My struts-config.xml contains the following action mapping:
<action path="/myAction"
type="org.springframework.web.struts.DelegatingAct ionProxy"
name="mForm"
scope="request"
parameter="method"
validate="false">
<forward name="success" path="/index.jsp" />
</action>
My spring config file has following reference:
<bean name="/Module/myAction"
class="MyAction">
<property name="test">
<ref bean="test"/>
</property>
</bean>
Everything works fine and struts is integrated perfectly but If i try to intercept the above struts action to put in a logging advice for exceptions it says that class has to be a struts action. Is this a limitation as far as struts can go with spring such that no advices can be applied to struts action classes ?
Another way around this is purely to use struts exception handler declared in the struts config file but in that case I am not able to get the action class name which actually throws the excpetion for logging purposes. Thats why I was looking at applying spring advices to struts action classes.
Any direction in this issue will be greatly appreciated.


Reply With Quote