(三十二)订单管理-查询订单详情

(三十二)订单管理-查询订单详情

查询订单详情
        点击每一个订单后面的订单详情,将该订单的oid通过ajax传递到后台查询
    步骤分析:
        给按钮添加事件

 /store/WebContent/admin/order/list.jsp

        <script type="text/javascript">
                function showDetail(oid){
                    //alert(oid);
                    $.post("${pageContext.request.contextPath}/adminOrder",{"method":"getDetailByOid","oid":oid},function(data){
                        var s="<table width='99%' border='1'><tr><th>商品名称</th><th>购买数量</th></tr>";
                        $(data).each(function(){
                            s+=("<tr><td>"+this.product.pname+"</td><td>"+this.count+"</td></tr>");
                        });
                        s+="</table>";
                        
                        layer.open({
                             type: 1,//0:信息框; 1:页面; 2:iframe层;    3:加载层;    4:tip层
                             title:"订单详情",//标题
                             area: ['450px', '300px'],//大小
                             shadeClose: true, //点击弹层外区域 遮罩关闭
                             content: s//内容
                        });
                    },"json");
                }
        </script>

/store/src/com/louis/web/servlet/AdminOrderServlet.java

/**
     * 查询订单详情
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public  String getDetailByOid(HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setContentType("text/html;charset=utf-8");
        
        //1.接受oid
        String oid = request.getParameter("oid");
        
        
        //2.调用serivce查询订单详情 返回值 list<OrderItem>
        OrderService os=(OrderService) BeanFactory.getBean("OrderService");
        List<OrderItem> items = os.getById(oid).getItems();
        
        
        //3.将list转成json 写回
        //排除不用写回去的数据
        JsonConfig config = JsonUtil.configJson(new String[]{"class","itemid","order"});
        JSONArray json = JSONArray.fromObject(items,config);
        //System.out.println(json);
        response.getWriter().println(json);
        return null;
    }    

导入layer

效果

问题:

json数据转化

 

posted on 2017-10-18 23:43 Michael2397 阅读(...) 评论(...) 编辑 收藏

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值