首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Struts2引文配置Action

2012-09-08 
Struts2注解配置Action???按照以上参考资料,我将以前用xml配置action的测试项目修改如下:???? ?action修改

Struts2注解配置Action

?

?

?

按照以上参考资料,我将以前用xml配置action的测试项目修改如下:

?

?

?? ?action修改如下

?

package com.testman.action;import java.util.List;import javax.annotation.Resource;import org.apache.struts2.config.Namespace;import org.apache.struts2.config.Result;import org.apache.struts2.config.Results;import com.opensymphony.xwork2.ActionSupport;import com.testman.bean.FundBalance;import com.testman.service.FundBalanceService;@Namespace("/fundbalance")@Results({@Result(name="list",value="/WEB-INF/page/fundbalance/fundbalancelist.jsp"),@Result(name="add",value="/WEB-INF/page/fundbalance/addfundbalance.jsp"),@Result(name="addUI",value="/WEB-INF/page/fundbalance/addfundbalance.jsp"),@Result(name="update",value="/WEB-INF/page/fundbalance/updatefundbalance.jsp"),@Result(name="updateUI",value="/WEB-INF/page/fundbalance/updatefundbalance.jsp"),@Result(name="query",value="/WEB-INF/page/fundbalance/fundbalancelist.jsp"),@Result(name="message",value="/WEB-INF/page/fundbalance/message.jsp")})//@Result("/index.jsp")public class FundBalanceAction extends ActionSupport{@Resource FundBalanceService fundBalanceService;private String message;private List<FundBalance> fundbalances;private FundBalance fundbalance;private String delkeys;public FundBalance getFundbalance() {return fundbalance;}public void setFundbalance(FundBalance fundbalance) {this.fundbalance = fundbalance;}/** */public String list(){this.fundbalances = fundBalanceService.getAllFundBalance();return "list";}/** */public String addUI(){return "add";}public String updateUI(){fundbalance = fundBalanceService.queryFundBalanceById(this.fundbalance).get(0);return "update";}/** */public String add(){this.fundBalanceService.save(this.fundbalance);this.message="数据保存成功!";return "message";}/** */public String update(){this.fundBalanceService.update(this.fundbalance);this.message="数据更新成功!";return "message";}public String query(){this.fundbalances = fundBalanceService.queryFundBalanceByYearMonthItem(this.fundbalance);return "query";}public String del(){if(this.delkeys.contains(",")){String[] keys = this.delkeys.split(",");    for(String key : keys){    if(!"".equals(key)){this.fundBalanceService.delete(key); }    }    }else{    this.fundBalanceService.delete(delkeys);    }this.message="数据删除成功!";return "message";}public List<FundBalance> getFundbalances() {return fundbalances;}public void setFundbalances(List<FundBalance> fundbalances) {this.fundbalances = fundbalances;}public String getMessage() {return message;}public void setMessage(String message) {this.message = message;}public String getDelkeys() {return delkeys;}public void setDelkeys(String delkeys) {this.delkeys = delkeys;}@Overridepublic String execute() throws Exception {// TODO Auto-generated method stubreturn SUCCESS;}}
?最后,页面上再把action的指向修改成 形如 fundBalance!add.action 即可。

热点排行