SelectAction.java
1 @SuppressWarnings("serial") 2 @Component("selectAction") 3 @Scope("prototype") 4 public class SelectAction extends BaseAction{ 5 6 private ISelectService selectService; 7 8 @Resource 9 public void setSelectService(ISelectService selectService) { 10 this.selectService = selectService; 11 } 12 13 public List<ReportFormBeans> reportlist; 14 public List<ReportFormBeans> getReportlist(){ 15 return reportlist; 16 } 17 public void setReportlist(List<ReportFormBeans> reportlist) { 18 this.reportlist = reportlist; 19 } 20 21 public String toReportGetter()throws Exception 22 { 23 24 try { 25 26 List<ReportFormBeans> list = new ArrayList<ReportFormBeans>(); 27 28 int i = 1; 29 int max = selectService.getReportCount(); 30 31 while(i <= max){ 32 ReportFormBeans reportFormBean = new ReportFormBeans(); 33 BeanUtils.copyProperties(reportFormBean , selectService.getReport(i)); 34 list.add(reportFormBean); 35 36 for (int j = 0; j < list.size(); j++) { 37 System.out.println(list.get(j)); 38 } 39 40 i++; 41 } 42 this.setReportlist(list); 43 return SUCCESS; 44 } catch (Exception e) { 45 e.printStackTrace(); 46 System.out.println("ERROR!"); 47 return INPUT; 48 } 49 } 50 }
select.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <%@ taglib prefix="s" uri="/struts-tags" %> 3 4 <% 5 String path = request.getContextPath(); 6 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 7 %> 8 9 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 10 <html> 11 <head> 12 <base href="<%=basePath%>"> 13 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 14 <title>注册页面</title> 15 <meta http-equiv="pragma" content="no-cache"> 16 <meta http-equiv="cache-control" content="no-cache"> 17 <meta http-equiv="expires" content="0"> 18 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 19 <meta http-equiv="description" content="This is my page"> 20 <!-- 21 <link rel="stylesheet" type="text/css" href="styles.css"> 22 --> 23 </head> 24 <body> 25 <s:iterator value="reportlist"> 26 <tr> 27 <td><s:property value="sid"/></td> 28 </tr> 29 </s:iterator> 30 <s:debug/> 31 </body> 32 </html>