我正在尝试在页面加载时从ActionSupport
JSP 页面名称中迭代请求属性,EnergyConsumptionAnalysis
以使用 struts2 使用相同的 JSP 页面在浏览器上显示它,但在运行时我得到空显示。谁能告诉我我在做什么错?
JSP:
<s:action name = "FetchSite"></s:action>
<s:iterator value="siteData">
<s:property value = "name"/>
</s:iterator>
行动支持:
public class EnergyAction extends ActionSupport implements ServletRequestAware
{
private HttpServletRequest request;
@Override
public String execute()
throws Exception {
//Get the site Data
EnergyAnalysisBusinessHandler handler = new EnergyAnalysisBusinessHandler();
//setting attribute as arraylist type
request.setAttribute("siteData", handler.getSiteData());
return SUCCESS;
}
public void setServletRequest(HttpServletRequest request){
this.request = request;
}
public HttpServletRequest getServletRequest(){
return request;
}
struts.xml:
<action name = "FetchSite" class = "com.javaworld.email.EnergyAction">
<result name = "success">jsp/EnergyConsumptionAnalysis.jsp
</result>
</action>