struts2单独使用时action由struts2自己负责创建;与spring集成时,action实例由spring负责创建(依赖注入)。这导致在两种情况下struts.xml配置文件的略微差异。
假如:LoginAction在包cn.edu.jlu.cs.action中。
1. struts2单独使用时,action的class属性为LoginAction的全路径名,如下:
<action name="login" class="cn.edu.jlu.cs.action.LoginAction">
2. struts2与spring集成时,class属性是spring的applicationContext.xml中配置的bean的id属性值。
---------------------------------------------------------------------------------------
//struts.xml
<action name="login" class="LoginAction">
----------------------------------------------------------------------------------------
//applicationContext.xml
<bean id="LoginAction" class="cn.edu.jlu.cs.action.LoginAction" />