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对象中的成员变量改如何处理
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对象中的成员变量改如何处理