• 一段可以使用的 hibernate获得对象->action存入List->jsp页面用<s:iterator>迭代的代码


    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>
  • 相关阅读:
    创建FLASK,同步docker
    FLASK Buleprint
    restful api
    Angular JS
    线程日志
    将项目部署到linux下的docker容器中
    安装和卸载docker
    学习目录总编
    Ansible
    装饰器
  • 原文地址:https://www.cnblogs.com/liuxiaoke/p/3457165.html
Copyright © 2020-2023  润新知