用struts2的iterator输出从数据库查出的数据,后台可以打印出来,前台却不能显示出来!为什么呢?
publicStringexecute()throwsException{HttpServletRequestrequest=ServletActionContext.g...
public String execute() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
//session.setAttribute("name", session.getAttribute("name"));
userBackupInfo.setName((String)session.getAttribute("name"));
Map req = (Map) ActionContext.getContext().get("request");
req.put("routelist", userService.routeCheckedList(userBackupInfo));
return SUCCESS;
} 展开
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
//session.setAttribute("name", session.getAttribute("name"));
userBackupInfo.setName((String)session.getAttribute("name"));
Map req = (Map) ActionContext.getContext().get("request");
req.put("routelist", userService.routeCheckedList(userBackupInfo));
return SUCCESS;
} 展开
3个回答
展开全部
首先在Action类中把你要输出的缺圆含list定义成一个属性伏笑、并先成set、get方法
如:Action类
private List<String> contentList ;
public List<String> getContentList() {
return contentList;
}
public void setContentList(List<String> contentList) {
this.contentList = contentList;
}
在你请求的Action方法中把获取的List数据 赋值给contentList
然后腔碧在前面页面直接用<s:iterator>标签遍历
<s:iterator value="contentList" id="content" >
<s:property value="content"/>
</s:iterator>
如:Action类
private List<String> contentList ;
public List<String> getContentList() {
return contentList;
}
public void setContentList(List<String> contentList) {
this.contentList = contentList;
}
在你请求的Action方法中把获取的List数据 赋值给contentList
然后腔碧在前面页面直接用<s:iterator>标签遍历
<s:iterator value="contentList" id="content" >
<s:property value="content"/>
</s:iterator>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询