`

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显示另一个列表

分享到:
评论

相关推荐

    SSI框架 spring Struts ibatis

    **SSI框架:Spring、Struts和iBatis的整合** 在Web开发领域,Spring、Struts和iBatis是三个非常重要的开源框架。它们分别在不同的层次上为开发者提供了强大的功能,而当这三个框架组合在一起时,就形成了所谓的SSI...

    struts2+spring+ibatis做的增删改查的小例子

    这个"struts2+spring+ibatis做的增删改查的小例子"是一个针对初学者的实践教程,旨在帮助学习者理解这三个框架如何协同工作以实现数据的CRUD(创建、读取、更新、删除)操作。 首先,Struts2作为MVC(Model-View-...

    Struts+Spring+Ibatis整合框架搭建配置文档

    ### Struts+Spring+Ibatis整合框架搭建配置详解 在当今复杂的软件开发环境中,整合不同的框架以构建高效、可维护的应用程序变得尤为重要。Struts、Spring与Ibatis(现称MyBatis)作为三个功能互补的Java框架,它们...

    struts2+spring+ibatis增删改查

    Struts2、Spring和iBatis是Java Web开发中常用的三大框架,它们分别负责MVC模式中的Action层、业务逻辑层和服务数据访问层。这个压缩包文件提供的是一种经典的整合使用这三个框架的案例,用于实现一个基础的CRUD...

    Spring+Struts2+IBatis 项目整合(四)

    在本项目整合中,我们将探讨如何将三个著名的技术框架——Spring、Struts2和IBatis——集成在一起,创建一个高效且灵活的企业级Web应用程序。这个整合通常被称为SSH(Spring、Struts2、Hibernate或iBatis)框架栈,...

    struts2+spring+ibatis实例

    Struts2、Spring和iBatis是Java Web开发中经典的三大框架,它们组合在一起形成了所谓的SSI(Struts2、Spring、iBatis)架构。这个实例项目提供了使用这些框架实现基本CRUD(创建、读取、更新、删除)操作以及分页...

    基于ssi struts_spring_ibatis 的一个增删 查 更新的小例子

    **SSI (Struts-Spring-Ibatis) 框架整合详解** 在Web开发领域,SSIStruts-Spring-Ibatis 是一种常见的企业级应用框架组合,它将三个强大的开源技术结合在一起,为开发者提供了一个高效、灵活且易于维护的开发环境。...

    webwork增删改简单入门例子(+spring+ibatis)

    在这个“webwork增删改简单入门例子(+spring+ibatis)”中,我们将探讨如何结合Spring和iBatis这两个流行的技术来构建一个基础的CRUD(创建、读取、更新、删除)应用。 1. WebWork基础知识: - 控制器:WebWork的...

    strut+spring+ibatis登录注册系统

    Struts2、Spring和iBatis是Java Web开发中常用的三个框架,它们组合起来可以构建出功能完善的MVC(Model-View-Controller)应用程序。这个"strut+spring+ibatis登录注册系统"是一个典型的实战项目,对于初学者来说,...

    struts1.2+ibatis+DWR2.0+MySql5.0增删改查的小例子

    Struts1.2、iBatis、DWR2.0和MySql5.0是Java Web开发中的四个重要组件,它们分别在MVC(模型-视图-控制器)架构的不同层面上发挥着关键作用。这个小例子展示了如何将这些技术整合在一起,实现一个基本的增删改查功能...

    struts2+spring+ibaits 增删查Demo

    在这个“Struts2+Spring+iBatis增删查Demo”中,我们将探讨这三个框架如何协同工作,实现数据的CRUD(创建、读取、更新、删除)操作。 首先,Struts2是一个开源的MVC(模型-视图-控制器)框架,用于构建基于Java ...

    struts-sping-ibatis 小例子很详细的

    相比于传统的 JDBC,iBatis 提供了一种更加灵活的方式,允许开发者直接编写 SQL 查询,然后通过 XML 或注解来绑定这些查询与 Java 对象。这样可以避免大量重复的 CRUD(创建、读取、更新、删除)代码,提高开发效率...

    struts+spring+ibaits配置详解

    ### Struts + Spring + iBatis 配置详解 #### 一、概述 在实际的软件开发项目中,为了提高代码的复用性与维护性,通常会采用一系列的框架来构建应用程序。其中,Struts、Spring 和 iBatis 是三个非常流行且互补的...

    SSI整合测试工程

    通常,Struts的Action会调用Spring管理的Service,Service再通过iBatis查询数据库,获取到的数据经过处理后传递给Struts的Action,最终由Struts的视图层(如JSP页面)进行渲染并展示给用户。 在压缩包文件名称列表...

    一个S2S+ibatis一个增删改查的例子(由原先SSH2改编)

    这个例子将展示如何在Struts2的动作类中调用iBatis的SQL映射文件来执行CRUD(创建、读取、更新和删除)操作。 1. **Struts2框架**:Struts2是Apache软件基金会的一个开源项目,它整合了WebWork的核心功能和Struts1...

    完整demo,框架ssi

    在本项目中,Ibatis可能会被用来处理数据库查询和CRUD(创建、读取、更新、删除)操作,与Spring结合时,可以实现更灵活的数据访问层。 **SSI集成** 指的是Spring、Struts和Ibatis的集成,这种集成提供了强大的功能...

    J2EE最新精品项目源码Struts2.0+Hibernate+Spring+ExtJS

    此外,它还支持多种视图技术,如JSP、FreeMarker等,并且与各种数据访问技术如Hibernate、iBatis等集成良好。 **Hibernate** 是一个对象关系映射(ORM)框架,它简化了Java应用程序对数据库的操作。Hibernate通过...

    SpringMvc+Ibatis包

    - `org.springframework.web.struts-3.0.5.RELEASE.jar`:Spring对Struts的支持,允许在Spring MVC之外集成Struts1框架,提供更多的Web应用选项。 - `dom4j-1.6.1.jar`:一个用于XML处理的Java库,提供了DOM,SAX和...

Global site tag (gtag.js) - Google Analytics