struts2_action标签中的class属性
struts2_action标签中的class属性,
如果不写,默认调用ActionSupport对象,调用它的execute()方法,固定返回“success”。
可以写调用java类
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<action name="index" class="com.bjsxt.struts2.front.action.IndexAction3">
<result name="success">/ActionIntroduction.jsp</result>
</action>
这个java类有三种写法:
1、普通java类
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
package com.bjsxt.struts2.front.action; public class IndexAction1 { public String execute() { return "success"; } }
2、实现Action接口
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
package com.bjsxt.struts2.front.action; import com.opensymphony.xwork2.Action; public class IndexAction2 implements Action { @Override public String execute() { return "success"; } }
3、继承ActionSupport类
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
package com.bjsxt.struts2.front.action; import com.opensymphony.xwork2.ActionSupport; public class IndexAction3 extends ActionSupport { @Override public String execute() { return "success"; } }
我们只用第三种,因为ActionSupport类写好了一系列将来可能用到的方法。