• 将jsp页面的<s:iterator>的数据返回到action


    jsp:

    <form method="post" id="createTable">
      <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
          <td height="10"></td>
        </tr>
        <tr id="tabtxt1" >
          <td valign="top" align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
           <tr>
              <td height="24">
                <label style="margin-left:50px; font-size:20px;">表名:</label>
                <input name="createTable.tableComments" type="text" class="input96 required" id="textfield3" maxlength="30" size="50" value="<s:property value="createTable.tableComments" />" />
              </td>
            </tr>
        <tr>
          <td height="10"></td>
          </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="2" class="td00 table table-striped table-bordered table-hover">
                <tr >
                  <th width="60px" >序号</th>
                  <th>字段名</th>
                  <th>字段类型</th>
                  <th width="10%" >操作</th>
                </tr>
                <s:iterator value="createTableColumnList" status="st">
                <tr>
                  <td align="center"><s:property value="#st.index+1"/></td>
                  <td align="center">
                    <input name="columnComments" class="input96 required" size="40" type="text" value="<s:property value="columnComments" />"/>
                  </td>
                  <td align="center">
                    <select name ="dataType" style="150px;" >
                          <option <s:if test="'VARCHAR2'==dataType"> selected </s:if> value="VARCHAR2">字符串</option>
                          <option <s:if test="'NUMBER(16)'==dataType"> selected </s:if> value="NUMBER(16)">整数</option>
                          <option <s:if test="'NUMBER(16,4)'==dataType"> selected </s:if> value="NUMBER(16,4)">小数</option>
                          <option <s:if test="'DATE'==dataType"> selected </s:if> value="DATE">日期</option>
                    </select>
                  </td>
                  <td align="center">
                  <a href="<%=request.getContextPath() %>/webmaster/filesmessage/createTableAction!deleteColumn.action">
                  <img src="<%=request.getContextPath() %>/webmaster/images/delete.gif" width="18" height="21" alt="删除" title="删除"></a></td>
                </tr>
                </s:iterator>
              </table></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
                  <td align="center">
                      <input  type="submit" id="addTable" class="btn btn-info" value="新增字段" onClick="addColumn('add')"/>
                      <input  type="submit" id="saveTable" class="btn btn-info" value="提交" onClick="addColumn('save')"/>
                      <input type="button" name="button" id="button" value="关闭" class="btn btn-light" onClick="window.close();return false();">
                  </td>
                  </tr>
                </table></td>
              </tr>
          </table>
          </td>
        </tr>
    </table>
    </form>
    View Code

    java:

    private List<CreateTableColumn> createTableColumnList;
    private String type;
    private String[] columnComments;
    private String[] dataType;
    
    public String addColumn() {
        if (null == createTableColumnList) {
            createTableColumnList = new ArrayList<>();
        }
        
        if (null != columnComments) {
            CreateTableColumn addCreateTableColumn = null;
            for (int i=0; i < columnComments.length; i++) {
                addCreateTableColumn = new CreateTableColumn();
                addCreateTableColumn.setColumnComments(columnComments[i]);
                addCreateTableColumn.setDataType(dataType[i]);
                createTableColumnList.add(addCreateTableColumn);
            }
        }
        
        if ("add".equals(type)) {
            CreateTableColumn addCreateTableColumn = new CreateTableColumn();
            createTableColumnList.add(addCreateTableColumn);
        } else {
            
        }
        
        return "createTableJsp";
    }
    
    public List<CreateTableColumn> getCreateTableColumnList() {
        return createTableColumnList;
    }
    
    public void setCreateTableColumnList(List<CreateTableColumn> createTableColumnList) {
        this.createTableColumnList = createTableColumnList;
    }
    
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
    
    public String[] getColumnComments() {
        return columnComments;
    }
    
    public void setColumnComments(String[] columnComments) {
        this.columnComments = columnComments;
    }
    
    public String[] getDataType() {
        return dataType;
    }
    
    public void setDataType(String[] dataType) {
        this.dataType = dataType;
    }
  • 相关阅读:
    浏览器的缓存机制
    浏览器渲染原理及优化
    flutter 安装 & 启动 windows
    从浏览器输入 url 到页面渲染
    压力测试简单案例
    Office2021简体中文离线安装包下载地址合集,目前最全! L
    pdfplumber yongqi
    MySQL中对varchar类型排序问题 yongqi
    基础知识串讲笔记2022124 yongqi
    Faker是一个Python包,,待学习 yongqi
  • 原文地址:https://www.cnblogs.com/BobXie85/p/9817914.html
Copyright © 2020-2023  润新知