• oracle 获取某表有那些字段,字段类型,长度,名称,注释等


    一个存储过程,或者说SQL,直接查询得到集合。其中核心的表是:user_tab_cols,user_col_commons

    View Code
     /************************************************************************************/
     /*  功能说明:根据表名查询表字段信息                                                */
     /*  参数说明:                                                                      */
     /*         i_table_name                             IN               VARCHAR2     表名                        */
     /*         o_cursor                  OUT  cursor_type       返回游标                */
     /*                                                                                  */
     /*  创建日期         姓名                                                           */
     /*  2013-05-06       路人甲                                                         */
     /*  COPYRIGHT(C) 2004                                                               */
     /*  PINGAN INSURANCE (GROUP) COMPANY OF CHINA.                                      */
     /*  ALL RIGHTS RESERVED .                                                           */
     /************************************************************************************/
    
    create or replace PROCEDURE p_list_table_column(  i_table_name       IN       VARCHAR2,
                                       o_cursor                 OUT      cursor_type)
    AS
    BEGIN
        begin
            open o_cursor for
                    select t1.table_name as tableName, 
                    t1.column_name as columnName, 
                    t1.data_type as dataType, 
                    t1.data_length as dataLength,
                    t2.comments as comments
                  from user_tab_cols t1, user_col_comments t2
                  where t1.table_name = t2.table_name
                   and t1.column_name = t2.column_name
                   and t1.table_name = upper(i_table_name);
        end;
    END p_list_table_column;

    调用获取方法,当前采用IBATIS操作:

    1、实体对象:

    View Code
    /**表管理对象
     * 
     * @author : 路人甲
     * @create_date :2013-5-6 上午08:57:15
     *
     */
    public class TableDataManagerDTO extends BaseDTO {
        
        /**
         * UID
         */
        private static final long serialVersionUID = 1824560673414067948L;
    
        // 表名
        private String tableName;
    
        // 字段名
        private String columnName;
    
        // 字段类型
        private String dataType;
    
        // 字段长度
        private BigDecimal dataLength;
    
        // 备注说明
        private String comments;
    
        public String getColumnName()
        {
            return columnName;
        }
    
        public void setColumnName(String columnName)
        {
            this.columnName = columnName;
        }
    
        public String getComments()
        {
            return comments;
        }
    
        public void setComments(String comments)
        {
            this.comments = comments;
        }
    
        public BigDecimal getDataLength()
        {
            return dataLength;
        }
    
        public void setDataLength(BigDecimal dataLength)
        {
            this.dataLength = dataLength;
        }
    
        public String getDataType()
        {
            return dataType;
        }
    
        public void setDataType(String dataType)
        {
            this.dataType = dataType;
        }
    
        public String getTableName()
        {
            return tableName;
        }
    
        public void setTableName(String tableName)
        {
            this.tableName = tableName;
        }
        
        
    }

    2、工具类:

    View Code
    package com.pingan.saims.scms.systemmanage.util;
    
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import com.opensymphony.oscache.util.StringUtil;
    import com.paic.pafa.app.web.exception.PafaWebException;
    import com.pingan.saims.scms.common.util.EXStringUtil;
    import com.pingan.saims.scms.systemmanage.dto.TableDataManagerDTO;
    import com.pingan.tsv2.tcms.common.util.CURDUtil;
    
    /**动态表获取SQL语句
     * 
     * @author : 路人甲
     * @create_date :2013-5-6 上午09:46:18
     *
     */
    public class TableDataManagerUtil
    {
        /**查询ID,都是以rowid为准**/
        public static final String SEARCH_ROWID = "rowid";
        /**查询条件,都是以rowid为准**/
        public static final String SEARCH_WHERE = "searchWhere";
        
        
        /**获取插入语句
         *  
         * @author : 路人甲
         * @create_date :2013-5-6 上午10:13:06
         * @param tableName 表名
         * @param columnList 字段列表
         * @param param 结果信息
         * @return
         */
        public static String getInsertSQL(String tableName, List<TableDataManagerDTO> columnList, Map<String, Object> param)
        {
            if (columnList == null || columnList.size() == 0)
            {
                return null;
            }
            StringBuffer sqlBuffer = new StringBuffer(50);
            StringBuffer sqlBuffer1 = new StringBuffer(50);
            StringBuffer sqlBuffer2 = new StringBuffer(50);
            for (TableDataManagerDTO column : columnList)
            {
    //             如果是空信息不作修改
                String value = EXStringUtil.stringNull2Str((String)param.get(column.getColumnName()));
                if (value.length() == 0)
                {
                    continue;
                }            
                
                if (sqlBuffer1.length() > 0)
                {
                    sqlBuffer1.append(",");
                }
                sqlBuffer1.append(column.getColumnName());
                
                if (sqlBuffer2.length() > 0)
                {
                    sqlBuffer2.append(",");
                }
                // 根据类型判断一下
                if (column.getDataType().equals("NUMBER"))// 数字
                {
                    sqlBuffer2.append("to_number(").append("'").append(value.replace(",", "")).append("')");
                }
                else if (column.getDataType().equals("DATE"))// 日期 必须都是 'yyyy-mm-dd hh24:mi:ss'
                {
                    sqlBuffer2.append("to_date(").append("'").append(value).append("', 'yyyy-mm-dd hh24:mi:ss')");
                }
                else
                {
                    sqlBuffer2.append("'").append(value).append("'");
                }
                
            }
            sqlBuffer.append("insert into ").append(tableName).append("(").append(sqlBuffer1).append(") values(").append(sqlBuffer2).append(")");
            
            return sqlBuffer.toString();
        }
        
        /**获取修改语句
         *  
         * @author : 路人甲
         * @create_date :2013-5-6 上午10:13:06
         * @param tableName 表名
         * @param columnList 字段列表
         * @param param 结果信息
         * @return
         */
        public static String getUpdateSQL(String tableName, List<TableDataManagerDTO> columnList, Map<String, Object> param)
        {
            if (columnList == null || columnList.size() == 0)
            {
                return null;
            }
            StringBuffer sqlBuffer = new StringBuffer(50);
            StringBuffer sqlBuffer1 = new StringBuffer(50);
            for (TableDataManagerDTO column : columnList)
            {
    //             如果是空信息不作修改
                String value = EXStringUtil.stringNull2Str((String)param.get(column.getColumnName()));
                if (value.length() == 0)
                {
                    continue;
                }
                
                if (sqlBuffer1.length() > 0)
                {
                    sqlBuffer1.append(",");
                }
                sqlBuffer1.append(column.getColumnName()).append(" = ");
                
                if (column.getDataType().equals("NUMBER"))// 数字
                {
                    sqlBuffer1.append("to_number(").append("'").append(value.replace(",", "")).append("')");
                }
                else if (column.getDataType().equals("DATE"))// 日期 必须都是 'yyyy-mm-dd hh24:mi:ss'
                {
                    sqlBuffer1.append("to_date(").append("'").append(value).append("', 'yyyy-mm-dd hh24:mi:ss')");
                }
                else
                {
                    sqlBuffer1.append("'").append(value).append("'");
                }
                
            }
            sqlBuffer.append("update ").append(tableName).append(" set ").append(sqlBuffer1).append(" where ").append(TableDataManagerUtil.SEARCH_ROWID).append(" = '").append(param.get(TableDataManagerUtil.SEARCH_ROWID)).append("'");;
            
            return sqlBuffer.toString();
        }
        
        /**获取删除语句
         *  
         * @author : 路人甲
         * @create_date :2013-5-6 上午10:13:06
         * @param tableName 表名
         * @param rowid 指定列ID
         * @return
         */
        public static String getDeleteSQL(String tableName, String rowid)
        {
            if (StringUtil.isEmpty(rowid))
            {
                return null;
            }
            StringBuffer sqlBuffer = new StringBuffer(50);
            sqlBuffer.append("delete from ").append(tableName).append(" where ").append(TableDataManagerUtil.SEARCH_ROWID).append(" = '").append(rowid).append("'");;
            
            return sqlBuffer.toString();
        }
        
        /**获取查询语句_根据ID
         * 
         * @author : 路人甲
         * @create_date :2013-5-6 上午10:36:53
         * @param tableName 表名
         * @param columnList 字段列表
         * @param rowid 指定列ID
         * @return
         */
        public static String getSelectSQL(String tableName, List<TableDataManagerDTO> columnList, String rowid)
        {
            Map<String, String> param = new HashMap<String, String>();
            param.put(TableDataManagerUtil.SEARCH_ROWID, rowid);
            return getSelectSQL(tableName, columnList, param);
        }
        
        /**获取查询语句_根据条件
         * 
         * @author : 路人甲
         * @create_date :2013-5-6 上午10:36:53
         * @param tableName 表名
         * @param columnList 字段列表
         * @param rowid 指定列ID
         * @return
         */
        public static String getSelectSQL(String tableName, List<TableDataManagerDTO> columnList, Map<String, String> param)
        {
            if (columnList == null || columnList.size() == 0)
            {
                return null;
            }
            StringBuffer sqlBuffer = new StringBuffer(50);
            StringBuffer sqlBuffer1 = new StringBuffer(50);
            for (TableDataManagerDTO column : columnList)
            {
                if (sqlBuffer1.length() > 0)
                {
                    sqlBuffer1.append(",");
                }
                sqlBuffer1.append(column.getColumnName());
                
            }
            sqlBuffer1.append(",").append(TableDataManagerUtil.SEARCH_ROWID).append("||'' as RID");
            sqlBuffer.append("select ").append(sqlBuffer1).append(" from ").append(tableName) ;
            
            if (param != null && param.size() > 0)
            {
                String searchWhere = param.get(TableDataManagerUtil.SEARCH_WHERE);
                String rowid = param.get(TableDataManagerUtil.SEARCH_ROWID);
                
                if (!StringUtil.isEmpty(rowid))
                {
                    sqlBuffer.append(" where ").append(TableDataManagerUtil.SEARCH_ROWID).append(" = '").append(rowid).append("'");
                }
                else if (!StringUtil.isEmpty(searchWhere))
                {
                    sqlBuffer.append(" where ").append(searchWhere);
                }
            }
            
            
            return sqlBuffer.toString();
        }
        
        /**获取表字段信息
         * 
         * @author : 路人甲
         * @create_date :2013-5-6 上午10:51:33
         * @param tableName
         * @return
         * @throws PafaWebException
         */
        @SuppressWarnings("unchecked")
        public static List<TableDataManagerDTO> getColunmListByTableName(String tableName) throws PafaWebException
        {
            Map<String,Object> paraMap = new HashMap<String, Object>(); // 参数Map
            if (StringUtil.isEmpty(tableName))
            {
                throw new PafaWebException("查询表结构异常,没有选择表名!");
            }
            paraMap.put("i_table_name", tableName);
            List<TableDataManagerDTO> columnList = CURDUtil.queryList("tableDataManagerResultList", paraMap); // 获取表结构
            return columnList;
        }
    }

    3、控制类:

    展示页:

    View Code
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
            Map model = new HashMap();
            String tableName = request.getParameter("tableName");
            String searchWhere = request.getParameter("searchWhere");
            try {
                Map<String, String> paramWhere = new HashMap<String, String>();
                paramWhere.put(TableDataManagerUtil.SEARCH_WHERE, searchWhere); // 查询where 后的语句
                List<TableDataManagerDTO> tableDataManagerDTOs = TableDataManagerUtil.getColunmListByTableName(tableName);
                String sql = TableDataManagerUtil.getSelectSQL(tableName, tableDataManagerDTOs, paramWhere);
                Map<String,Object> paraMap = new HashMap<String, Object>(); // 结果信息
                paraMap.put("sql", sql);
                List resultList = CURDUtil.queryList("tableDataManager_list", paraMap);
                model.put("resultList", resultList);
                model.put("tableDataManagerDTOs", tableDataManagerDTOs);
                model.put("tableName", tableName);
                return new ModelAndView(successView, model);
            } catch (PafaWebException e){
                traceLogger.log(this.getClass().getName(), Level.COMMON_ERROR, this
                        .getClass().getName(), "参数:tableName=" + tableName + "系统管理_系统参数设置_表数据维护_查询,发生错误:", JobUtils.getExceptionDetail(e));
                return ExceptionUtils.returnForAjaxErrorView(new PafaWebException("系统管理_系统参数设置_表数据维护_查询,出现异常:" + JobUtils.getExceptionDetail(e)));
            }
        }
    
    
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
            Map model = new HashMap();
            String pageType = request.getParameter("pageType");
            try {
                String tableName = request.getParameter("tableName");
                List<TableDataManagerDTO> tableDataManagerDTOs = TableDataManagerUtil.getColunmListByTableName(tableName);
                // 获取公共类型信息
                CommonInfoDTO commonInfoDTO = BaseCommonCache.getInstanceNew().getCommonInfoDTO(BaseCommonConstants.COMMON_TYPE_29, tableName);
                
                model.put("tableDataManagerDTOs", tableDataManagerDTOs);
                model.put("pageType", pageType);
                model.put("commonInfoDTO", commonInfoDTO);
                
                if ("insert".equals(pageType)) // 新增
                {
                    // 生成序列ID
                }
                else if ("update".equals(pageType)) // 修改
                {
                    String rowid = request.getParameter("rowid");
                    String sql = TableDataManagerUtil.getSelectSQL(tableName, tableDataManagerDTOs, rowid);
                    if (StringUtil.isEmpty(sql))
                    {
                        throw new PafaWebException("查询类型参数异常,没有获取到查询表 "+tableName+" 的语句!");
                    }
                    Map<String,Object> paraMap = new HashMap<String, Object>(); // 结果信息
                    paraMap.put("sql", sql);
                    model.put("resultObj", CURDUtil.queryObject("tableDataManager_list", paraMap));
                }
                else
                {
                    throw new PafaWebException("查询类型参数异常,不存在类型为["+pageType+"]的操作!");
                }
                
                return new ModelAndView(successView, model);
            } catch (PafaWebException e) {
                traceLogger.log(this.getClass().getName(), Level.COMMON_ERROR, this
                        .getClass().getName(), "参数:" + pageType+",发生错误:"+ e, "");
                return ExceptionUtils.returnForAjaxErrorView(new PafaWebException("转向表修改,出现异常:"+e.getMessage()));
            }
        }

    操作页:

    View Code
    package com.pingan.saims.scms.systemmanage.web.controller.tableDataManager;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    
    import com.paic.pafa.app.lwc.core.context.support.PafaCoreContexton;
    import com.paic.pafa.app.web.exception.PafaWebException;
    import com.paic.pafa.app.web.servlet.ModelAndView;
    import com.paic.pafa.app.web.servlet.mvc.AbstractController;
    import com.paic.pafa.logging2.Level;
    import com.paic.pafa.logging2.Logger;
    import com.pingan.saims.scms.systemmanage.dto.TableDataManagerDTO;
    import com.pingan.saims.scms.systemmanage.util.TableDataManagerUtil;
    import com.pingan.tsv2.tcms.common.util.CURDUtil;
    import com.pingan.tsv2.tcms.common.util.ExceptionUtils;
    import com.pingan.tsv2.tcms.common.util.ViewNames;
    
    /**系统管理_系统参数设置_表数据维护_保存
     * 
     * @author : 路人甲
     * @create_date :2013-5-3 下午04:53:23
     *
     */
    @SuppressWarnings("unchecked")
    public class TableDataManagerSaveController extends AbstractController{
    
        //        日志
        private Logger traceLogger = PafaCoreContexton.getInstance().getTracer();
        
        protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
            // 获取当前登陆用户信息
            HttpSession session = request.getSession();
            Map loginInfo = (Map) session.getAttribute("logonInfo");
            Map model = new HashMap();
            String pageType = request.getParameter("pageType");
            try {
                String tableName = request.getParameter("tableName");
                List<TableDataManagerDTO> columnList = TableDataManagerUtil.getColunmListByTableName(tableName);
                Map<String,Object> requestMap = new HashMap<String, Object>(); // 页面获取的Map
                String sql = "";
                
                model.put("tableDataManagerDTO", columnList);
                // 获取页面传输过来的参数
                for (TableDataManagerDTO column : columnList)
                {
                    requestMap.put(column.getColumnName(), request.getParameter(column.getColumnName()));
                }
                if ("insert".equals(pageType)) // 新增
                {
                    sql = TableDataManagerUtil.getInsertSQL(tableName, columnList, requestMap);
                }
                else if ("update".equals(pageType)) // 修改
                {
                    requestMap.put(TableDataManagerUtil.SEARCH_ROWID, request.getParameter(TableDataManagerUtil.SEARCH_ROWID));
                    sql = TableDataManagerUtil.getUpdateSQL(tableName, columnList, requestMap);
                }
                else if ("delete".equals(pageType)) // 删除
                {
                    String rowid = request.getParameter(TableDataManagerUtil.SEARCH_ROWID);
                    sql = TableDataManagerUtil.getDeleteSQL(tableName, rowid);
                }
                else
                {
                    throw new PafaWebException("查询类型参数异常,不存在类型为["+pageType+"]的操作!");
                }
                Map<String,Object> paraMap = new HashMap<String, Object>(); // 参数信息
                paraMap.put("sql", sql);
                CURDUtil.insert("tableDataManager_save", paraMap, loginInfo); // 执行SQL语句
                return new ModelAndView(ViewNames.AJAX_SUCCESS_VIEW, model);
            } catch (PafaWebException e) {
                traceLogger.log(this.getClass().getName(), Level.COMMON_ERROR, this.getClass().getName(), "参数:" + pageType+",发生错误:"+ e, "");
                return ExceptionUtils.returnForAjaxErrorView(new PafaWebException("系统管理_系统参数设置_表数据维护_保存,出现异常:"+e.getMessage()));
            }
        }
    }

    4、SQL-MAP配置:

    View Code
    <!-- 表数据维护 结果集 class="java.util.HashMap"-->
         <resultMap id="tableDataManagerResultMap" class="com.pingan.saims.scms.systemmanage.dto.TableDataManagerDTO">
            <result property="tableName" column="tableName"/>
            <result property="columnName" column="columnName"/>
            <result property="dataType" column="dataType"/>
            <result property="dataLength" column="dataLength"/>
            <result property="comments" column="comments"/>
        </resultMap>
        <!-- 表数据维护 参数 -->    
        <parameterMap id="tableDataManagerParamMap" class="java.util.Map">
             <parameter property="i_table_name" javaType="java.lang.String" jdbcType="VARCHAR" mode="IN" />
             <parameter property="o_cursor" javaType="java.sql.ResultSet" jdbcType="ORACLECURSOR" mode="OUT" />
         </parameterMap>     
        <!-- 表数据维护查询 调用存储过程 -->
         <procedure id="tableDataManagerResultList" resultMap="tableDataManagerResultMap" parameterMap="tableDataManagerParamMap">
            {call scms_statistics_packge.p_list_table_column(?,?)}
        </procedure>
        <!-- 修改 -->
        <update id="tableDataManager_save" parameterClass="java.util.Map">
              $sql$
        </update>
        <!-- 查询 -->
        <select id="tableDataManager_list" resultClass="java.util.HashMap" remapResults="true" parameterClass="java.util.HashMap">
              $sql$
        </select>

    5、列表页面展示:

    View Code
    <script language="javascript">
        //动态刷新
        function refreshForm(){
            $("refreshForm").submit();
        }
        var detail=null;
        function showWindow(url, pageType){
         var iWidth=820;
         var iHeight=600;
            //获得窗口的垂直、水平位置
           var iTop = (window.screen.availHeight-30-iHeight)/2;        
           var iLeft = (window.screen.availWidth-10-iWidth)/2;   
            if(detail&&detail.open&&!detail.closed) {
                alert("新增窗口已打开!请先关闭后再打开!");
                detail.focus();
                return false;
            }
            else{
                detail=window.open("about:blank","_timeDeposit_win",'status,scrollbars,resizable,left='+iLeft+',top='+iTop+',width='+iWidth+',height='+iHeight);
            }
            popupForm.action = url;
            popupForm.target = "_timeDeposit_win";
            popupForm.pageType.value = pageType;
            popupForm.submit();
            detail.focus();
        }
        
        // 修改
        function updateBtn()
        {
            var rowid = $("rowid").value;
            if(rowid == "")
            {
                alert("请选择要修改的信息!");
                return false;
            }
            var url = "/tableDataManagerSaveToController.do?rowid="+rowid;
            showWindow(url, "update");
        }
        // 删除
        function deleteBtn()
        {
            var rowid = $("rowid").value;
            if(rowid == "")
            {
                alert("请选择要删除的信息!");
                return false;
            }
            if (confirm("您确定删除这条信息吗?"))
            {
                var url = "/tableDataManagerSaveController.do?pageType=delete&tableName=<c:out value='${tableName }' />&rowid="+rowid;
                Ajax.loading(url,function(data){
                    alert("删除成功!");
                    refreshForm();
                },false);
            }
        }
        // 选中ID
        function selectedId(rowid)
        {
            // 设置要操作的信息值
            $("rowid").value=rowid;
        }
    </script>
    
    <body bgcolor="#EBEEF7" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    
    <form name="refreshForm" method="post" action="/tableDataManagerListController.do">
        <input type="hidden" name="tableName" value="<c:out value='${tableName }' />"/>
        <input type="hidden" name="searchWhere" value="<c:out value='${searchWhere }' />"/>
    </form>
    <form action="" name="popupForm" id="popupForm" method="post">
        <input type="hidden" name="tableName" value="<c:out value='${tableName }' />"/>
        <input type="hidden" name="pageType" value=""/>
    </form>
    <form name="inputForm" id="inputForm" >
    <input type="hidden" name="rowid" id="rowid" value=""/>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" id="inputTable" class="table_1" STRIPED="false" SELECTABLE="true">
      <tr align="center" class="FixedTitleRow">     
      <!---->
      <td nowrap height="25%" class="td_1">选择</td>
      <c:forEach var="tableDataManagerDTO" items="${tableDataManagerDTOs}" varStatus="j">
          <td nowrap height="25%" class="td_1"><c:out value="${tableDataManagerDTO.columnName }"/><br />(<c:out value="${tableDataManagerDTO.comments }"/>)</td>      
      </c:forEach>
      </tr>
      <tbody class="datatab"  dtolist="abclist">
      <c:if test="${empty resultList}">
      <tr align="center"> 
        <td nowrap class="td_3" colspan="20">没有与查询条件相匹配的数据!</td>
      </tr>
      </c:if>
      <c:forEach var="conferMsg" items="${resultList}" varStatus="i" >
      <tr align="center" > 
        <td nowrap class="td_3">
          <input type="radio" name="id" value="<c:out value="${conferMsg['RID'] }" />" onclick="selectedId('<c:out value="${conferMsg['RID'] }" />');"/>
        </td>
          <c:forEach var="tableDataManagerDTO" items="${tableDataManagerDTOs}" varStatus="j">
            <td nowrap class="td_3">
            <c:choose>
                <c:when test="${tableDataManagerDTO.dataType eq 'DATE' }"><fmt:formatDate pattern="yyyy-MM-dd" value="${conferMsg[tableDataManagerDTO.columnName] }"/></c:when>
                <c:when test="${tableDataManagerDTO.dataType eq 'NUMBER' }"><fmt:formatNumber pattern="#,##0.00" value="${conferMsg[tableDataManagerDTO.columnName] }"/></c:when>
                <c:otherwise><c:out value="${conferMsg[tableDataManagerDTO.columnName] }" /></c:otherwise>
            </c:choose>
            </td>
        </c:forEach>
      </tr>
      </c:forEach>
      </tbody>  
    </table>
    </form>
    <table width="100%">
    <tr><td>&nbsp;</td></tr>
      <tr> 
      <td align="center">
            <input type="button" name="insertBtn" id="insertBtn" class="button23" onclick="updateBtn();" value="修改" />&nbsp;&nbsp;
            <input type="button" name="insertBtn" id="insertBtn" class="button23" onclick="deleteBtn();" value="删除" />
        </td>
      </tr>
    </table>
    </body>

    添加修改页:

    View Code
    <jsp:useBean id="dateNow" class="java.util.Date" />
    <script language="javascript">
      //初始Form
      var init = function() {
        new FormCheck("inputForm",{validateChange:false,allowReSubmit:true,ajax:true,beforeSubmit:beforeSubmit,onAjaxSuccess:gotoPage,ajaxError:gotoFail});
      }
      window.addEvent('domready', init);
    
      //返回提交结果,刷新父页面
      function gotoPage() {
        alert("保存成功!");
        window.close();
        opener.refreshForm();
      }
      
      function beforeSubmit() {
        $("save").disabled=true;
      }
      function gotoFail() {
        $("save").disabled=false;
      }
    </script>
    <body bgcolor="#EBEEF7" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
         <td nowrap height="30" class="address">&nbsp;&middot;当前位置:系统管理&gt;&gt;系统参数设置&gt;&gt;表数据维护&gt;&gt;
         <c:if test="${pageType eq 'update' }">修改</c:if>
         </td>               
      </tr>
    </table>
    <!-- 用款释放信息 -->
    <form name="inputForm" method="post" action="/tableDataManagerSaveController.do">
    <input type="hidden" name="pageType" value="<c:out value="${pageType }"/>">
    <input type="hidden" name="rowid" value="<c:out value="${resultObj['RID'] }"/>">
    <input type="hidden" name="tableName" id="tableName" value="<c:out value="${commonInfoDTO.commonValue }" />"/>
    <table width="98%" border="0" cellpadding="0" cellspacing="0" id="listTable" class="table_1" >
        <tr align="center">
            <td  class="td_1_1">数据表名:<br />
              (在公共类型中修改配置,类型type=29)</td>
              <td  align="left"  class="td_3_3" colspan="3">
                  <c:out value="${commonInfoDTO.commonValue }" />(<c:out value="${commonInfoDTO.commonName }" />)
            </td>
        </tr>
        <tr align="center">
        <c:forEach var="tableDataManagerDTO" items="${tableDataManagerDTOs }" varStatus="i">
            <c:if test="${i.index > 0 and i.index%2==0 }">
            </tr>
            <tr align="center">
            </c:if>
            <td  class="td_1_1"><c:out value="${i.index+1 }" /><c:out value='${tableDataManagerDTO.columnName }' /><br />(<c:out value='${tableDataManagerDTO.comments }' />)</td>
              <td  align="left"  class="td_3_3">
              <c:choose>
                  <c:when test="${tableDataManagerDTO.columnName eq 'CREATED_BY' 
                              or  tableDataManagerDTO.columnName eq 'UPDATED_BY' }">
                      <!-- 特殊处理(创建人、修改人) -->
                      <c:choose>
                          <c:when test="${empty resultObj }">
                              <input type="text" style="height:20px;" 
                                  name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  class="input1" 
                                  value="<c:out value='${userInfo.userUID }' />" />
                          </c:when>
                          <c:when test="${!empty resultObj and tableDataManagerDTO.columnName eq 'CREATED_BY'}">
                              <input type="text" style="height:20px;" 
                                  name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  class="input1" 
                                  value="<c:out value='${resultObj[tableDataManagerDTO.columnName]}' />" />
                          </c:when>
                          <c:otherwise>
                              <input type="text" style="height:20px;" 
                                  name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  class="input1" 
                                  value="<c:out value='${userInfo.userUID }' />" />
                          </c:otherwise>
                      </c:choose>
                  </c:when>
                  <c:when test="${tableDataManagerDTO.columnName eq 'DATE_CREATED' 
                              or  tableDataManagerDTO.columnName eq 'DATE_UPDATED' }">
                      <!-- 特殊处理(创建时间、修改时间) -->
                     <c:choose>
                          <c:when test="${empty resultObj }">
                              <input type="text" style="height:20px;" size="20"  
                                  name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  class="input2"
                                  value="<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${dateNow }"/>" />
                          </c:when>
                          <c:when test="${!empty resultObj and tableDataManagerDTO.columnName eq 'DATE_CREATED'}">
                              <input type="text" style="height:20px;" size="20"  
                                  name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  class="input2"
                                  value="<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${resultObj[tableDataManagerDTO.columnName]}"/>" />
                          </c:when>
                          <c:otherwise>
                              <input type="text" style="height:20px;" size="20" 
                                  name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                  class="input2 " 
                                  value="<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${dateNow }"/>" />
                          </c:otherwise>
                      </c:choose>         
                  </c:when>
                  <c:otherwise>
                      <c:choose>
                          <c:when test="${tableDataManagerDTO.dataType eq 'NUMBER' }">
                          <!-- 数字 -->
                          <input type="text" style="height:20px;" 
                              name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                              id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                              maxlength="<c:out value='${tableDataManagerDTO.dataLength}' />" 
                              class="validate['number[<c:out value='${tableDataManagerDTO.dataLength}' />]'] input1" 
                              value="<c:out value='${resultObj[tableDataManagerDTO.columnName]}' />" />
                          </c:when>
                          <c:when test="${tableDataManagerDTO.dataType eq 'DATE' }">
                          <!-- 日期 -->
                          <input type="text" style="height:20px;" size="20"
                              name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                              id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                              class="input2"
                              value="<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${resultObj[tableDataManagerDTO.columnName] }"/>" />
                          </c:when>
                          <c:otherwise>
                              <c:choose>
                                  <c:when test="${tableDataManagerDTO.dataLength > 40}">
                                      <textarea cols="30" rows="2" 
                                          name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                          id="<c:out value='${tableDataManagerDTO.columnName }' />"><c:out value='${resultObj[tableDataManagerDTO.columnName]}' /></textarea>
                                  </c:when>
                                  <c:when test="${tableDataManagerDTO.dataLength < 5}">
                                      <input type="text" style="height:20px;" size="5"
                                          name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                          id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                          maxlength="<c:out value='${tableDataManagerDTO.dataLength}' />" 
                                          class="input1" 
                                          value="<c:out value='${resultObj[tableDataManagerDTO.columnName]}' />" />
                                  </c:when>
                                  <c:otherwise>
                                      <input type="text" style="height:20px;" size="<c:out value='${tableDataManagerDTO.dataLength}' />"
                                          name="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                          id="<c:out value='${tableDataManagerDTO.columnName }' />" 
                                          maxlength="<c:out value='${tableDataManagerDTO.dataLength}' />" 
                                          class="input1" 
                                          value="<c:out value='${resultObj[tableDataManagerDTO.columnName]}' />" />
                                  </c:otherwise>
                              </c:choose>
                          </c:otherwise>
                      </c:choose>
                  </c:otherwise>
              </c:choose>
              </td>
        </c:forEach>
        </tr>
    </table>
    <br>
    <table width="100%">
        <tr align="center">
          <td  align="center" colspan="2">
            <input type='button' class="button4 validate['submit']" name='save' id='save' value="提交" />
            <input type="button" name="btnClose" value="关闭" onClick="javascript:window.close();" class="button23" />
          </td>
        </tr>
    </table>
    </form>
    </body>
  • 相关阅读:
    [轉]SQLServer : EXEC和sp_executesql的区别
    CSS 中文字体
    [转]71种 menu css源码
    DataTable做為數據源手動分頁
    [轉]9个优秀的基于 JavaScript 与 CSS 的 Web 图表框架
    [轉]10 Tools to help you select a Web 2.0 Color Palette
    [轉]ASP模拟POST提交请求上传文件
    Web配色資源
    [轉]sqlhelper 下载 使用指南
    [轉]查看SQL Server数据库连接
  • 原文地址:https://www.cnblogs.com/a393060727/p/3065123.html
Copyright © 2020-2023  润新知