当前位置: 代码迷 >> JavaScript >> JSP spring struts ibatis JS展示列表,查询,直接读取显示
  详细解决方案

JSP spring struts ibatis JS展示列表,查询,直接读取显示

热度:462   发布时间:2012-09-19 13:43:54.0
JSP spring struts ibatis JS显示列表,查询,直接读取显示

1、页面

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../include/mytaglib.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商品组管理</title>
<link rel="shortcut icon" href="<%=request.getContextPath()%>/img/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/blueprint/admin.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/pis/pis.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/pis/new_screen.css" media="screen, projection">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/pis/new_typography.css" media="screen, projection">

    <link type="text/css" href="<%=request.getContextPath()%>/css/datatable/page.css" rel="stylesheet" />
    <link type="text/css" href="<%=request.getContextPath()%>/css/datatable/table.css" rel="stylesheet" />
    <link type="text/css" href="<%=request.getContextPath()%>/js/datatable/themes/ui-lightness/jquery-ui-1.8.4.custom.css" rel="stylesheet" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/jqueryUI/themes/base/jquery.ui.all.css">
   
     <style type="text/css">
    tr {height: 20px;}
    th {    background: #0066FF;color: #FFFFFF;line-height: 20px;height: 20px;}
    td {    white-space: nowrap;border-bottom: 1px solid #95bce2;vertical-align: top;height: 20px;    }
    tr.alt td{ background: #ecf6fc;    }
    tr.over td{ background: #bcd4ec; }
    </style>       
<script type="text/javascript" src="<%=request.getContextPath()%>/js/datatable/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/datatable/jquery.dataTables.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/formjson.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/json2.js"></script>

<script src="<%=request.getContextPath()%>/jqueryUI/external/jquery.bgiframe-2.1.2.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.core.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.widget.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.mouse.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.button.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.draggable.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.position.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.resizable.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.dialog.js"></script>
<script src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.effects.core.js"></script>

<script type="text/javascript" src="<%=request.getContextPath()%>/js/jsdate/jsdate.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsTree4JQuery/jquery.jstree4new.js"></script>
<script language="javascript">
var oTable = null;
$(function() {
    $( "#reset-btn" ).button().click(function() {
        resetF();
    });
    $( "#query-btn" ).button().click(function() {
        searchF();
    });
    $( "#add-btn" ).button().click(function() {
        addproductgroup();
    });   
   
});       
function addproductgroup(){
    window.location.href="<%=request.getContextPath()%>/product/productGroupManagement_gotoAddProductGroup.do";
};
function resetF(){
//    document.getElementById("contentForm").reset();
}
    //"检索"按钮的处理函数
    function searchF() {
        if (oTable == null) { //仅第一次检索时初始化Datatable
            oTable = $('#queryResultTbl').dataTable( {
                "bAutoWidth": true,                    //自动计算列宽度
               
                "bProcessing": true,                    //加载数据时显示正在加载信息
                "bServerSide": true,                    //指定从服务器端获取数据
                "bFilter": false,                        //不使用过滤功能
                "bLengthChange": true,                    //false 则用户不可改变每页显示数量
            //    "iDisplayLength": curPageNum,                    //每页显示8条数据
                "sAjaxSource": "<%=request.getContextPath()%>/product/queryProductGroupManagement_queryGroupByThreeFactor.do?svctime=" + new Date().getTime(),//获取数据的url
                "fnServerData": retrieveData,            //获取数据的处理函数
               
                "bStateSave": true ,//保存状态到cookie *************** 很重要 , 当搜索的时候页面一刷新会导致搜索的消失。使用这个属性就可避免了
        //        "bRetrieve":true,
            /** x滚动条 */
            //    "sScrollX": "100%",
            //    "sScrollXInner": "400%",
            //    "bScrollCollapse": true,
               
                "bSort": false,//排序
                //设置要排序的列
//                "aaSorting": [ [ 11, "desc" ] ],
                "aoColumns": [
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 }
                    ],
               
                "sPaginationType": "full_numbers",        //翻页界面类型 //two_button  //full_numbers
               
                "oLanguage": {
                        "sProcessing": "正在加载数据...",
                        "sLengthMenu": "每页显示 _MENU_ 条记录",
                        "sZeroRecords": "没有检索到数据",
                        "sInfo": "当前数据为从第 _START_ 到第 _END_ 条数据;总共有 _TOTAL_ 条记录",
                        "sInfoEmpty": "记录数为0",
                        "sInfoFiltered": "(全部记录数 _MAX_  条)",
                        "sInfoPostFix": "",
                       
                        "oPaginate": {
                            "sFirst": "首页",
                            "sPrevious": "前页",
                            "sNext": "后页",
                            "sLast": "尾页"
                        }
                }
               
            });
        }else{
        //刷新Datatable,会自动激发retrieveData
            oTable.fnDraw();
        }
       
    }
    String.prototype.replaceAll = function (AFindText,ARepText){
        raRegExp = new RegExp(AFindText,"g");
        return this.replace(raRegExp,ARepText);
    };       
    //自定义数据获取函数,比价报表显示 ajax json
    function retrieveData( sSource, aoData ,fnCallback ) {
        genParams4Search(aoData);
        jsonText =  '{"jsonParams":' +  JSON.stringify(aoData) + '}';
        jsonText = jsonText.replaceAll("true","\"yes\"");
       
        $.ajaxSetup({cache:false});
        $.ajax( {
            "type": "POST",
            "contentType": "application/json",
            "url": sSource,
            "dataType": "json",
            "data": jsonText ,
            "success": function(oRequest) {
                fnCallback(oRequest);
                init4AjRule();
            }
        });
    }   
   
    function init4AjRule(){
        //添加鼠标动作监听
        $("#tobyContent td div a[name='editA']").each(
            function(){
                $(this).click(function(){
//                    if (confirm("确实要修改吗?")) {
//                    }
                        var theId = $(this).attr("id").replaceAll("alink_e_","");
                        window.location.href = "<%=request.getContextPath()%>/product/productGroupManagement_showProductGroupInfo.do?theId="+theId;
                });
            }   
        );       
        $("#tobyContent td div a[name='viewA']").each(
            function(){
                $(this).click(function(){
                    var theId = $(this).attr("id").replaceAll("alink_v_","");
                    window.location.href = "<%=request.getContextPath()%>/product/productGroupManagement_gotoShowProducts.do?key2.id="+theId;
                });
            }   
        );       
        $("#tobyContent td div a[name='deleteA']").each(
            function(){
                $(this).click(function(){
                    if (confirm("确实要删除吗?")) {
                        var theId = $(this).attr("id").replaceAll("alink_d_","");
                        window.location.href = "<%=request.getContextPath()%>/product/productGroupManagement_deleteByProductGroupId.do?theId="+theId;
                    }
                });
            }   
        );               
    }
   
    function genParams4Search(aoData){
        //这里传递页面参数
        aoData.push( { "name": "groupName", "value": $("#groupName").val() } );
        aoData.push( { "name": "startDate", "value": $("#Txt_StartDate").val() } );
        aoData.push( { "name": "endDate", "value": $("#Txt_EndDate").val() } );
    }
   
</script>
</head>
<body onload="searchF()">
 <div class="pis_width">
     <!-- head begin -->
     <jsp:include page="../include/head_top.jsp" />
     <!-- head end -->
     <!-- left begin -->
     <jsp:include page="../include/left_menu.jsp" />    
     <!-- left end -->

     <!-- content begin -->
     <div class="pis_content">
     <div><font color="red"><b>您的位置:系统管理 > 商品组管理</b></font></div>
    </br>
<s:form action="" method="post" namespace="/product">
商品组名称:<input type="text" class="text ui-widget-content ui-corner-all" style="width: 200px;" id="groupName" name="key2.groupName"/>
添加时间:<input type="text" class="text ui-widget-content ui-corner-all" style="width: 80px;" name="key2.startDate" maxlength="10" id="Txt_StartDate" descTxt="开始日期" readonly="readonly" onclick="SelectDate(this,'yyyy-MM-dd')" /> -
          <input type="text" class="text ui-widget-content ui-corner-all" style="width: 80px;" name="key2.endDate" maxlength="10" id="Txt_EndDate" descTxt="结束日期" readonly="readonly" onclick="SelectDate(this,'yyyy-MM-dd')" />
<%--
添加人<input type="text" class="text ui-widget-content ui-corner-all"  style="width: 100px;" id="groupName" name="key2.addPerson"/>
 --%>

<br/>
</s:form>
<button id="query-btn">查  询</button>&nbsp;&nbsp;&nbsp;
<button id="reset-btn">重  置</button>&nbsp;&nbsp;&nbsp;
<button id="add-btn">添加商品组</button>&nbsp;&nbsp;&nbsp;
<div id="dataTopDiv">
    <%--查询结果 --%>
    <table class="display" id="queryResultTbl">
    <thead>
        <tr id="headTitle">
            <th  style="background-color: #5eaeae" >编号</th>
            <th  style="background-color: #5eaeae" >商品组名称</th>
            <th  style="background-color: #5eaeae" >备注</th>
            <th  style="background-color: #5eaeae" >添加时间</th>
            <th  style="background-color: #5eaeae" >添加人</th>
            <th  style="background-color: #5eaeae" >操作</th>
        </tr>
    </thead>
        <tbody id="tobyContent">
            <tr>
                <td colspan="6"></td>
            </tr>
        </tbody>
    </table>
</div>
</div>
</div>
</body>
</html>
?

?

2、ACTION

public class QueryProductGroupManagementAction extends BaseAction{

    private static final long serialVersionUID = 1L;
    private PCSBusiness pcsBusiness = null;
    //private FilterKey key2;
    public String queryGroupByThreeFactor()throws IllegalAccessException, InvocationTargetException{
        //将查询结果以列表的形式显示在页面
        //参数请求设置为json形式
        JSONArray params = JSONArray.fromObject(jsonParams);
        Map<String, String> nameMap = convertToMap(jsonParams);
        FilterKey key2 = new FilterKey();
        convertToList( jsonParams ,key2.getSortNames(),nameMap);
       
        //设置key的值
        convertToKey(params, key2);
        String sEcho = key2.getsEcho();
       
        List<TProductGroupDTO> dtoList = null;
        //查询排序
        TProductGroupDTO tpg = new TProductGroupDTO();
        tpg.setGroupName(key2.getGroupName());
        //tpg.setAddPerson(key2.getAddPerson());//在此处暂时不用该搜索项
        tpg.setStartDate(key2.getStartDate());
        tpg.setEndDate(key2.getEndDate());
        tpg.setStartFrom(Integer.parseInt(key2.getiDisplayStart()));
        tpg.setLengthInteger(Integer.parseInt(key2.getiDisplayLength()));
        dtoList = pcsBusiness.getGroupByThreeFactor(tpg);//主要的查询步骤
        //设置总数
        Integer count=pcsBusiness.getGroupCountByThreeFactor(tpg);
        if (count <= 0) {
             jsonResponse = successed( count,sEcho );        
            return "queryGroupByThreeFactor";
        }
        if (dtoList == null || dtoList.isEmpty()) {
             jsonResponse = successed( count,sEcho );            
            return "queryGroupByThreeFactor";
        }
         int record = dtoList.size();
         String[][] data = new String[record][];
         for(int i=0; i<record; i++) {
             TProductGroupDTO dto = (TProductGroupDTO)dtoList.get(i);
         JSONProductGroup jsonDTO = new JSONProductGroup();
         BeanUtils.copyProperties(jsonDTO, dto);
         data[i] = jsonDTO.toArray(i);
         }
         DataTableReturnObject returnObject =
             new DataTableReturnObject(count.longValue(), count.longValue(), sEcho, data);
         jsonResponse = successed(returnObject);    
        return "queryGroupByThreeFactor";
    }

    public String showProductsByFilterCond()throws IllegalAccessException, InvocationTargetException{
        //将查询结果以列表的形式显示在页面
        //参数请求设置为json形式
        FilterKey key2 = new FilterKey();
        JSONArray params = JSONArray.fromObject(jsonParams);
        Map<String, String> nameMap = convertToMap(jsonParams);
        convertToList( jsonParams ,key2.getSortNames(),nameMap);
       
        //设置key的值
        convertToKey(params, key2);
        String sEcho = key2.getsEcho();
       
        List<TProductBackDTO> dtoList = null;
        //查询排序
        Integer id = Integer.parseInt(key2.getId());
        List<TPGroupCondDTO> tpgcdto = pcsBusiness.queryByProductGroupId(id);//得到对应的筛选条件的值和信息
        SelectStringDTO ssDTO = new SelectStringDTO();
        String selectString="where 1=1";
        String categorySelectString ="";
        for (int i = 0; i < tpgcdto.size(); i++) {//遍历list里面的对象
            TPGroupCondDTO tpgcDTO =tpgcdto.get(i);
            if (tpgcDTO.getFilterId()==0) {//分类的相关处理
                if (tpgcDTO.getLowerOrUper()==2) {//2级分类相关处理
                        categorySelectString+=" OR "+"tpr.category_id_lv2 in "+"("+tpgcDTO.getColumnValue()+")";
                }else if (tpgcDTO.getLowerOrUper()==3) {//3级分类相关处理
                        categorySelectString+=" OR "+"tpr.category_id_lv3 in "+"("+tpgcDTO.getColumnValue()+")";
                }else if (tpgcDTO.getLowerOrUper()==4) {//4级分类相关处理
                        categorySelectString+=" OR "+"tpr.category_id_lv4 in "+"("+tpgcDTO.getColumnValue()+")";
                }
            }else {
            TFilterCondDTO tFilterCondDTO =  pcsBusiness.queryTFilterCondById(tpgcDTO.getFilterId());
            if (tpgcDTO.getValueDone()==3) {
                selectString+=" AND " + tFilterCondDTO.getColumnName()+" > "+tpgcDTO.getColumnValue();
            }
            else if (tpgcDTO.getValueDone()==4) {
                selectString+=" AND " + tFilterCondDTO.getColumnName()+" < "+tpgcDTO.getColumnValue();
            }else if (tpgcDTO.getValueDone()==2) {//like和=全当like来操作
                selectString+=" AND " + tFilterCondDTO.getColumnName()+" like "+"'%"+tpgcDTO.getColumnValue()+"%'";
            }
            }
        }
        if(categorySelectString.equals("") || categorySelectString ==null)
        {
           
        }else {
            categorySelectString=" 1=0 "+categorySelectString;
            selectString+=" AND "+"("+categorySelectString+")";
        }
        String otherSelectString=selectString;
        selectString+=" LIMIT "+key2.getiDisplayLength()+" OFFSET "+key2.getiDisplayStart();
        ssDTO.setSelectStr(selectString);
        dtoList = pcsBusiness.queryProductsByFilterCond(ssDTO);
        //设置总数
        ssDTO.setSelectStr(otherSelectString);
        Integer count=pcsBusiness.queryProductsCount(ssDTO);
        if (count <= 0) {
             jsonResponse = successed( count,sEcho );        
            return "showProductsByFilterCond";
        }
        if (dtoList == null || dtoList.isEmpty()) {
             jsonResponse = successed( count,sEcho );            
            return "showProductsByFilterCond";
        }
         int record = dtoList.size();
         String[][] data = new String[record][];
         for(int i=0; i<record; i++) {
             TProductBackDTO dto = (TProductBackDTO)dtoList.get(i);
         JSONProductOfGroup jsonDTO = new JSONProductOfGroup();
         BeanUtils.copyProperties(jsonDTO, dto);
         data[i] = jsonDTO.toArray(i);
         }
         DataTableReturnObject returnObject =
             new DataTableReturnObject(count.longValue(), count.longValue(), sEcho, data);
         jsonResponse = successed(returnObject);    
        return "showProductsByFilterCond";
    }
    
    private void convertToKey(JSONArray params,FilterKey key)  {
        if (params != null && params.size() > 0) {
            for (int i = 0; i < params.size(); i++) {
                 
                try {
                    if (
                            String.valueOf(((JSONObject) (params.get(i)))
                            .get("name")).contains("iSortingCols")
                            ||
                            String.valueOf(((JSONObject) (params.get(i)))
                                    .get("name")).contains("bSortable_")
                            ||
                            String.valueOf(((JSONObject) (params.get(i)))
                                    .get("name")).contains("iSortCol_")    
                            ||
                            String.valueOf(((JSONObject) (params.get(i)))
                                    .get("name")).contains("sSortDir_")                                
                                   
                    ) {
                        continue;
                    }
                   
                    BeanUtil.setProperty(key,  String.valueOf(((JSONObject) (params.get(i)))
                            .get("name")),  ((JSONObject) (params
                                    .get(i))).get("value") )    ;
                } catch (IllegalArgumentException e) {
                    System.out.println("IllegalArgumentException " + e.getMessage());
                    e.printStackTrace();
                }catch (IllegalAccessException e) {
                    System.out.println("IllegalAccessException " + e.getMessage());
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    System.out.println("InvocationTargetException " + e.getMessage());
                    e.printStackTrace();
                } catch (NoSuchMethodException e) {
                    // TODO Auto-generated catch block
                    System.out.println("NoSuchMethodException" + e.getMessage());
                    e.printStackTrace();
                }    
            }
        }
    }
    public PCSBusiness getPcsBusiness() {
        return pcsBusiness;
    }
    public void setPcsBusiness(PCSBusiness pcsBusiness) {
        this.pcsBusiness = pcsBusiness;
    }
    public static long getSerialversionuid() {
        return serialVersionUID;
    }

//    public FilterKey getKey2() {
//        return key2;
//    }
//
//    public void setKey2(FilterKey key2) {
//        this.key2 = key2;
//    }
    
}
?

?

3、配置

<action name="queryProductGroupManagement_*" method="{1}" class="queryProductGroupManagement">
            <interceptor-ref name="json" />
            <result name="queryGroupByThreeFactor" type="json">
                <param name="root">jsonResponse.returnObject</param>
            </result>
            <result name="showProductsByFilterCond" type="json">
                <param name="root">jsonResponse.returnObject</param>
            </result>
</action> 
?

?

? 4、DTO

package com.yihaodian.pcs.dto;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.yihaodian.pcs.json.JSONParam;

public class FilterKey {
    private String id;
    private String productCode;
   
    private String productName;

    private String[] filterId;
   
    private String[] keyValue;
   
    private String[] hasTwoFilter;
   
    private String[] category;
    /**用于搜索*/
    private String addPerson;
    /**开始日期*/
    private String startDate;
    /**结束日期*/
    private String endDate;
    /**商品组名称*/
    private String groupName;
    /**商品组备注*/
    private String remark;
   
    private List<JSONParam> sortNames = new ArrayList<JSONParam>();
    private String sEcho;
    private String sColumns;
    private String iColumns;
    private String iDisplayStart;
    private String iDisplayLength;
   
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getGroupName() {
        return groupName;
    }
    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
    public String getAddPerson() {
        return addPerson;
    }
    public void setAddPerson(String addPerson) {
        this.addPerson = addPerson;
    }
    public String getStartDate() {
        return startDate;
    }
    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }
    public String getEndDate() {
        return endDate;
    }
    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }
    public String getProductCode() {
        return productCode;
    }
    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }
    public String getProductName() {
        return productName;
    }
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public String[] getFilterId() {
        return filterId;
    }
    public void setFilterId(String[] filterId) {
        this.filterId = filterId;
    }
    public String[] getKeyValue() {
        return keyValue;
    }
    public void setKeyValue(String[] keyValue) {
        this.keyValue = keyValue;
    }
    public String[] getHasTwoFilter() {
        return hasTwoFilter;
    }
    public void setHasTwoFilter(String[] hasTwoFilter) {
        this.hasTwoFilter = hasTwoFilter;
    }
    public String[] getCategory() {
        return category;
    }
    public void setCategory(String[] category) {
        this.category = category;
    }
    public List<JSONParam> getSortNames() {
        return sortNames;
    }
    public void setSortNames(List<JSONParam> sortNames) {
        this.sortNames = sortNames;
    }
    public String getsEcho() {
        return sEcho;
    }
    public void setsEcho(String sEcho) {
        this.sEcho = sEcho;
    }
    public String getsColumns() {
        return sColumns;
    }
    public void setsColumns(String sColumns) {
        this.sColumns = sColumns;
    }
    public String getiColumns() {
        return iColumns;
    }
    public void setiColumns(String iColumns) {
        this.iColumns = iColumns;
    }
    public String getiDisplayStart() {
        return iDisplayStart;
    }
    public void setiDisplayStart(String iDisplayStart) {
        this.iDisplayStart = iDisplayStart;
    }
    public String getiDisplayLength() {
        return iDisplayLength;
    }
    public void setiDisplayLength(String iDisplayLength) {
        this.iDisplayLength = iDisplayLength;
    }
}
package com.yihaodian.pcs.dto;

import java.io.Serializable;
import java.util.Date;

public class TProductGroupDTO implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    /** 主键 */
    private Integer id;
    /** 名称 */
    private String groupName;
    /** 备注 */
    private String remark;
    /**添加日期*/
    private String addDate;
    /**添加人*/
    private String addPerson;
   
    /**查询需要添加的变量字段*/
    /**开始日期*/
    private String startDate;
    /**结束日期*/
    private String endDate;
   
    private Integer startFrom;
   
    private Integer lengthInteger;
   
    /////////////
    private String categroyId2 ;
    private String categroyId3 ;
    private String categroyId4 ;
    private String otherSiteIds ;
   
    public Integer getStartFrom() {
        return startFrom;
    }

    public void setStartFrom(Integer startFrom) {
        this.startFrom = startFrom;
    }

    public Integer getLengthInteger() {
        return lengthInteger;
    }

    public void setLengthInteger(Integer lengthInteger) {
        this.lengthInteger = lengthInteger;
    }

    public String getAddDate() {
        return addDate;
    }

    public void setAddDate(String addDate) {
        this.addDate = addDate;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getAddPerson() {
        return addPerson;
    }

    public void setAddPerson(String addPerson) {
        this.addPerson = addPerson;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCategroyId2() {
        return categroyId2;
    }

    public String getCategroyId3() {
        return categroyId3;
    }

    public String getCategroyId4() {
        return categroyId4;
    }

    public String getOtherSiteIds() {
        return otherSiteIds;
    }

    public void setCategroyId2(String categroyId2) {
        this.categroyId2 = categroyId2;
    }

    public void setCategroyId3(String categroyId3) {
        this.categroyId3 = categroyId3;
    }

    public void setCategroyId4(String categroyId4) {
        this.categroyId4 = categroyId4;
    }

    public void setOtherSiteIds(String otherSiteIds) {
        this.otherSiteIds = otherSiteIds;
    }

}
?

?

5、SQL

?

<select id="getGroupByThreeFactor" parameterClass="com.yihaodian.pcs.dto.TProductGroupDTO"
        resultClass="com.yihaodian.pcs.dto.TProductGroupDTO">
        select tpg.id,tpg.group_name as groupName,tpg.remark,tpg.add_date as addDate,tpg.add_person as addPerson
        from pisdb.t_product_group as tpg
        where 1=1
        <isNotNull property="groupName">
            AND group_name like '%$groupName$%'
        </isNotNull>
        <isNotNull property="startDate">
        <isNotEmpty property="startDate">
            AND date_trunc('day', add_date)   <![CDATA[ >= ]]>  to_date(#startDate# , 'yyyy-MM-dd' )
            </isNotEmpty>
        </isNotNull>
        <isNotNull property="endDate">
        <isNotEmpty property="endDate">
            AND date_trunc('day', add_date)   <![CDATA[ <= ]]>  to_date(#endDate# , 'yyyy-MM-dd' )
            </isNotEmpty>
        </isNotNull>
        <isNotNull property="addPerson">
            <isNotEmpty property="addPerson">
            AND add_person like '%$addPerson$%'
            </isNotEmpty>
        </isNotNull>
        limit #lengthInteger# offset #startFrom#;
    </select>
?

?

6、另一个页面显示列表

window.location.href = "<%=request.getContextPath()%>/product/productGroupManagement_gotoShowProducts.do?key2.id="+theId;

<result name="gotoShowProducts">/webpage/productgroupmanagement/list/pre_browse_pro_analyse.jsp
            </result>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../include/mytaglib.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商品组的商品列表</title>
<link rel="shortcut icon"
    href="<%=request.getContextPath()%>/img/favicon.ico"
    type="image/x-icon" />
<link rel="stylesheet" type="text/css"
    href="<%=request.getContextPath()%>/css/blueprint/admin.css" />
<link rel="stylesheet" type="text/css"
    href="<%=request.getContextPath()%>/css/pis/pis.css" />
<link rel="stylesheet" type="text/css"
    href="<%=request.getContextPath()%>/css/pis/new_screen.css"
    media="screen, projection">
<link rel="stylesheet" type="text/css"
    href="<%=request.getContextPath()%>/css/pis/new_typography.css"
    media="screen, projection">

<link type="text/css"
    href="<%=request.getContextPath()%>/css/datatable/page.css"
    rel="stylesheet" />
<link type="text/css"
    href="<%=request.getContextPath()%>/css/datatable/table.css"
    rel="stylesheet" />
<link type="text/css"
    href="<%=request.getContextPath()%>/js/datatable/themes/ui-lightness/jquery-ui-1.8.4.custom.css"
    rel="stylesheet" />
<link rel="stylesheet"
    href="<%=request.getContextPath()%>/jqueryUI/themes/base/jquery.ui.all.css">

<style type="text/css">
tr {
    height: 20px;
}

th {
    background: #0066FF;
    color: #FFFFFF;
    line-height: 20px;
    height: 20px;
}

td {
    white-space: nowrap;
    border-bottom: 1px solid #95bce2;
    vertical-align: top;
    height: 20px;
}

tr.alt td {
    background: #ecf6fc;
}

tr.over td {
    background: #bcd4ec;
}
</style>
<script type="text/javascript"
    src="<%=request.getContextPath()%>/js/datatable/jquery.js"></script>
<script type="text/javascript"
    src="<%=request.getContextPath()%>/js/datatable/jquery.dataTables.js"></script>
<script type="text/javascript"
    src="<%=request.getContextPath()%>/js/formjson.js"></script>
<script type="text/javascript"
    src="<%=request.getContextPath()%>/js/json2.js"></script>

<script
    src="<%=request.getContextPath()%>/jqueryUI/external/jquery.bgiframe-2.1.2.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.core.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.widget.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.mouse.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.button.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.draggable.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.position.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.resizable.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.ui.dialog.js"></script>
<script
    src="<%=request.getContextPath()%>/jqueryUI/ui/jquery.effects.core.js"></script>

<script type="text/javascript"
    src="<%=request.getContextPath()%>/js/jsdate/jsdate.js"></script>
<script type="text/javascript"
    src="<%=request.getContextPath()%>/jsTree4JQuery/jquery.jstree4new.js"></script>
<script type="text/javascript"
    src="<%=request.getContextPath()%>/webpage/filtercond/filtercond.js"></script>
<script language="javascript">
var oTable = null;
    //"检索"按钮的处理函数
    function searchF() {
        if (oTable == null) { //仅第一次检索时初始化Datatable
            oTable = $('#queryResultTbl').dataTable( {
                "bAutoWidth": true,                    //自动计算列宽度
               
                "bProcessing": true,                    //加载数据时显示正在加载信息
                "bServerSide": true,                    //指定从服务器端获取数据
                "bFilter": false,                        //不使用过滤功能
                "bLengthChange": true,                    //false 则用户不可改变每页显示数量
            //    "iDisplayLength": curPageNum,                    //每页显示8条数据
                "sAjaxSource": "<%=request.getContextPath()%>/product/queryProductGroupManagement_showProductsByFilterCond.do?svctime=" + new Date().getTime(),//获取数据的url
                "fnServerData": retrieveData,            //获取数据的处理函数
               
                "bStateSave": true ,//保存状态到cookie *************** 很重要 , 当搜索的时候页面一刷新会导致搜索的消失。使用这个属性就可避免了
        //        "bRetrieve":true,
            /** x滚动条 */
            //    "sScrollX": "100%",
            //    "sScrollXInner": "400%",
            //    "bScrollCollapse": true,
               
                "bSort": false,//排序
                //设置要排序的列
//                "aaSorting": [ [ 11, "desc" ] ],
                "aoColumns": [
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 },
                                { "bSortable": 0 }
                    ],
               
                "sPaginationType": "full_numbers",        //翻页界面类型 //two_button  //full_numbers
               
                "oLanguage": {
                        "sProcessing": "正在加载数据...",
                        "sLengthMenu": "每页显示 _MENU_ 条记录",
                        "sZeroRecords": "没有检索到数据",
                        "sInfo": "当前数据为从第 _START_ 到第 _END_ 条数据;总共有 _TOTAL_ 条记录",
                        "sInfoEmpty": "记录数为0",
                        "sInfoFiltered": "(全部记录数 _MAX_  条)",
                        "sInfoPostFix": "",
                       
                        "oPaginate": {
                            "sFirst": "首页",
                            "sPrevious": "前页",
                            "sNext": "后页",
                            "sLast": "尾页"
                        }
                }
               
            });
        }else{
        //刷新Datatable,会自动激发retrieveData
            oTable.fnDraw();
        }
       
    }
    String.prototype.replaceAll = function (AFindText,ARepText){
        raRegExp = new RegExp(AFindText,"g");
        return this.replace(raRegExp,ARepText);
    };       
    //自定义数据获取函数,比价报表显示 ajax json
    function retrieveData( sSource, aoData ,fnCallback ) {
        genParams4Search(aoData);
        jsonText =  '{"jsonParams":' +  JSON.stringify(aoData) + '}';
        jsonText = jsonText.replaceAll("true","\"yes\"");
       
        $.ajaxSetup({cache:false});
        $.ajax( {
            "type": "POST",
            "contentType": "application/json",
            "url": sSource,
            "dataType": "json",
            "data": jsonText ,
            "success": function(oRequest) {
                fnCallback(oRequest);
                init4AjRule();
            }
        });
    }   
   
    function init4AjRule(){
        //添加鼠标动作监听
        $("#tobyContent td div a[name='changeA']").each(
            function(){
                $(this).click(function(){
                    var theId = $(this).attr("id").replaceAll("alink_d_","");
                    window.location.href = "<%=request.getContextPath()%>/product/productGroupManagement_deleteByProductGroupId.do?key2.id="+theId;
               
                });
            }   
        );       
    }
   
    function genParams4Search(aoData){
        //这里传递页面参数
        aoData.push( { "name": "id", "value": <%=request.getParameter("key2.id")%> } );
    }
   
</script>
</head>
<body onload="searchF()">
    <div class="pis_width">
        <!-- head begin -->
        <jsp:include page="../../include/head_top.jsp" />
        <!-- head end -->
        <!-- left begin -->
        <jsp:include page="../../include/left_menu.jsp" />
        <!-- left end -->

        <!-- content begin -->
        <div class="pis_content">
            <div>
                <font color="red"><b>您的位置:系统管理 > 商品组管理> 商品列表</b>
                </font>
                <input id="test" type="hidden" name="key2.id" value="<%=request.getParameter("key2.id")%>"/>
            </div>
            </br>
            <div id="dataTopDiv">
                <%--查询结果 --%>
                <table class="display" id="queryResultTbl">
                    <thead>
                        <tr id="headTitle">
                            <th style="background-color: #5eaeae">序号</th>
                            <th style="background-color: #5eaeae">产品编号</th>
                            <th style="background-color: #5eaeae">名称</th>
                            <th style="background-color: #5eaeae">BAND</th>
                            <th style="background-color: #5eaeae">周售额(元)</th>
                            <th style="background-color: #5eaeae">毛利</th>
                        </tr>
                    </thead>
                    <tbody id="tobyContent">
                        <tr>
                            <td colspan="6"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            </div>
            </div>
            </body>
            </html>
?

?

得到数据源在此页面进行。可以用来编辑,传id,或根据id显示另一个列表

  相关解决方案