java吧 关注:1,240,929贴子:12,714,725
  • 2回复贴,共1

求教大神一个Struts2页面的取值问题

只看楼主收藏回复

public class ShowVoteAction extends ActionSupport {
public String execute() {
VoteDaoImpl voteDao = VoteDaoFactory.getVoteDaoImplInstance();
VoteOptionDaoImpl voteOptionDao = VoteOptionDaoFactory.getVoteOptionDaoInstance();
List<Vote> votes = voteDao.findAllVoteImpl();
List<VoteResult> voteResults = new ArrayList<VoteResult>();
for(int i = 0;i < votes.size() ;i++) {
VoteResult voteResult = new VoteResult();
List<VoteOption> voteOptions = voteOptionDao.findVoteOptionByVoteIDImpl(votes.get(i).getVoteID());
Vote vote = votes.get(i);
voteResult.setVote(vote);
voteResult.setList(voteOptions);
voteResults.add(voteResult);
}
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("voteResults", voteResults);
return SUCCESS;
}
}
这是我的action代码,若要在jsp页面中取出voteResults中voteOptions的VoteOption对象中的成员变量改如何处理


IP属地:广东1楼2013-11-05 22:24回复
    页面用JSTL表达式迭代,或者struts标签迭代。


    IP属地:湖北来自Android客户端2楼2013-11-05 22:57
    收起回复