bug记录(1)

第一个:

                在编写一个远程调用接口时,远程传过来的是一个PDF报表文件,PrintWrite打印出来。在用httpclient远程访问时,发现打印报表为空白。

public String postreport(String url, Map<String, String> params) {
        String resp = null;
        CloseableHttpClient httpclient = HttpClients.createDefault();

        HttpPost httppost = new HttpPost(url);
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();

        Set<String> keySet = params.keySet();
        for (String key : keySet) {
            formparams.add(new BasicNameValuePair(key, params.get(key)));
        }
        try {
            UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(formparams, ApplicationConstant.UTF_8);
            httppost.addHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
            httppost.setHeader("Accept", "application/json");
            uefEntity.setContentType("text/json");
            httppost.setEntity(uefEntity);
            httppost.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 600000);
            CloseableHttpResponse response = httpclient.execute(httppost);

            HttpEntity entity = response.getEntity();
            if (entity != null) {
                //这里是问题所在。去掉后面的编码就能正常打印报表
                <span style="color:#FF0000;">resp = EntityUtils.toString(entity, ApplicationConstant.UTF_8);</span>
            }
            response.close();

        } catch (IOException e) {
            LOGGER.error("HttpClientUtil.post(),{}", e);
            resp = ApplicationConstant.FAIL_CODE;
        } finally {
            try {
                httpclient.close();
            } catch (IOException e) {
                LOGGER.error("HttpClientUtil.post(),{}", e);
                resp = ApplicationConstant.FAIL_CODE;
            }
        }
        return resp;
    }

第二个:

              请求远程Jasperreports报表接口时,每次调用发现接口运行了2次。研究发现这与浏览器下载机制有关。Google和火狐都会出现这种情况,而IE却不会。先这样,下次在具体补充。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值