struts-action.xml
<!-- start -->
<action name="createPay" class="orderPayAction" method="createPay" />
<action name="queryPay" class="orderPayAction" method="queryPay" />
<!-- end -->
而這個struts-action.xml 會透過struts.xml(主struts設定檔)中被匯入
ex:
<struts>
<constant name="struts.action.extension" value="action" />
<!--允許動態方法調用-->
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<!--該屬性設置Struts 2應用是否使用開發模式。如果設置該屬性為true,則可在應用出錯時顯示更多的出錯提示。-->
<constant name="struts.devMode" value="false" />
<constant name="struts.multipart.maxSize" value="5242880" />
//.....intercepter等....
<include file="conf/entry/struts-action.xml"></include> //透過include匯入struts-action.xml
</struts>
orderPayAction :
//@Controller及Scope("prototype") 記得要加
// 關於Scope("prototype") 有兩個網站可供參考
1.http://www.mkyong.com/spring/spring-bean-scopes-examples/ 2.http://zhidao.baidu.com/question/423772269.html
//由上1的網站教學" You can also use annotation to define your bean scope.",
//所以spring內要設定<context:component-scan base-package="com.XXX.*"></context:component-scan>
@Controller
@Scope("prototype")
public class OrderPayAction extends BaseAction<OrderPayVO> { //當然BaseAction繼承了ActionSupport ..前一篇有介紹
@Autowired
@Override
public void setVo(OrderPayVO vo) {
this.vo = vo;
}
@Autowired
private IOrderPayBO orderPayBO;
public String createPay(){
}
public String queryPay(){
}
}
以上就是struts 的action 先透過struts管理,再使用springMvc的方式進入action的class
留言列表