SelectAction.java
@SuppressWarnings("serial")
@Component("selectAction")
@Scope("prototype")
public class SelectAction extends BaseAction{ private ISelectService selectService; @Resource
public void setSelectService(ISelectService selectService) {
this.selectService = selectService;
} public List<ReportFormBeans> reportlist;
public List<ReportFormBeans> getReportlist(){
return reportlist;
}
public void setReportlist(List<ReportFormBeans> reportlist) {
this.reportlist = reportlist;
}
public String toReportGetter()throws Exception
{ try { List<ReportFormBeans> list = new ArrayList<ReportFormBeans>();
int i = 1;
int max = selectService.getReportCount(); while(i <= max){
ReportFormBeans reportFormBean = new ReportFormBeans();
BeanUtils.copyProperties(reportFormBean , selectService.getReport(i));
list.add(reportFormBean); for (int j = 0; j < list.size(); j++) {
System.out.println(list.get(j));
} i++;
}
this.setReportlist(list);
return SUCCESS;
} catch (Exception e) {
e.printStackTrace();
System.out.println("ERROR!");
return INPUT;
}
}
}
select.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %> <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注册页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<s:iterator value="reportlist">
<tr>
<td><s:property value="sid"/></td>
</tr>
</s:iterator>
<s:debug/>
</body>
</html>