zoukankan      html  css  js  c++  java
  • ajax请求springmvc返回json乱码

     $jq.ajax({
                    url: '${/request/@context_path}/hls/hlssignattachmentcontroller'+'?frameworkAgreementId='+frameworkAgreementId+'&userId='+userId,
                    method: 'get',
                    success: function (args) {
                        Leaf.showMessage('提示', args.message);
                        Leaf.Masker.unmask(Ext.getBody(), '${l:HLS.EXECUTING}');
                        return;
                    },
    

    java controller

      @RequestMapping(value = {"/hls/hlssignattachmentcontroller"}, produces = "application/json;charset=UTF-8")//produces不生效
        @ResponseBody
        public ResponseData  sendInfo(HttpServletResponse response, Integer frameworkAgreementId, Integer userId) {
            ResponseData responseData = new ResponseData();
            response.setContentType("text/html;charset=utf-8");//添加后生效
            try {
                iSignAttachmentService.sendInfo(frameworkAgreementId, userId);
                responseData.setSuccess(true);
                responseData.setMessage(HfaConstant.SUCCESS_MSG);
                return responseData;
            } catch (ParamsException e) {
                e.printStackTrace();
                responseData.setSuccess(false);
                responseData.setMessage(e.getMsg());
                return responseData;
            }
            catch (ServiceException e) {
                e.printStackTrace();
                responseData.setSuccess(false);
                responseData.setMessage(e.getMessage());
                return responseData;
            }
            catch (Exception e) {
                e.printStackTrace();
                responseData.setSuccess(false);
                responseData.setMessage(e.getMessage());
                return responseData;
            }
        }
    

    原因:返回对象为json形式
    参考https://www.cnblogs.com/roy-blog/p/7048401.html

  • 相关阅读:
    Azure HPC Pack Cluster添加辅助节点
    Azure HPC Pack 辅助节点模板配置
    Azure HPC Pack配置管理系列(PART6)
    Windows HPC Pack 2012 R2配置
    Azure HPC Pack 节点提升成域控制器
    Azure HPC Pack VM 节点创建和配置
    Azure HPC Pack 部署必要条件准备
    Azure HPC Pack 基础拓扑概述
    Azure VM 性能计数器配置
    Maven私仓配置
  • 原文地址:https://www.cnblogs.com/jinit/p/13229307.html
Copyright © 2011-2022 走看看