`

ajax 乱码

 
阅读更多

// 异步通过订单获得订单明细,用于商品价格修改
    @RequestMapping(value = "/storemanager/store/order/getdetail/price", method = RequestMethod.GET)
    public void getdetail(@RequestParam Long orderId, HttpServletResponse response) {
        response.setCharacterEncoding("UTF-8");
        log.debug("save credit valuation");
        OrderInfo orderInfo = orderInfoService.find(orderId);
        Set<OrderDetail> orderDetails = orderInfo.getOrderDetails();
        if(orderDetails!=null && orderDetails.size()>0){
            for(OrderDetail od : orderDetails){
                String productName = od.getProductName();
                log.debug("productName before : " + productName);
                /*try {
                    productName = new String(productName.getBytes("iso8859-1"),"UTF-8");
                    log.debug("productName after : " + productName);
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }*/
                od.setProductName(productName);
            }
        }
       
        String outStr = new JSONSerializer().serialize(orderDetails);
        log.debug("outStr is : " + outStr);
        PrintWriter pw = null;
        try {
            pw = response.getWriter();
            pw.write(outStr);
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            pw.close();
        }
    }

分享到:
评论
1 楼 tywo45 2011-10-31  
如果可能的话,建议把数据库的编码设成utf-8,这样就不用。。。。了

相关推荐

Global site tag (gtag.js) - Google Analytics