工作周记

1、httpclient出现乱码可能是由于发过来的东西是压缩过的,所以解压一下就行了

  1.  httpclient.addRequestInterceptor(new HttpRequestInterceptor() {  
  2.             
  3.            public void process(  
  4.                    final HttpRequest request,   
  5.                    final HttpContext context) throws HttpException, IOException {  
  6.                if (!request.containsHeader("Accept-Encoding")) {  
  7.                    request.addHeader("Accept-Encoding""gzip");  
  8.                }  
  9.            }  
  10.   
  11.        });  
  12.          
  13.        httpclient.addResponseInterceptor(new HttpResponseInterceptor() {  
  14.             
  15.            public void process(  
  16.                    final HttpResponse response,   
  17.                    final HttpContext context) throws HttpException, IOException {  
  18.                HttpEntity entity = response.getEntity();  
  19.                Header ceheader = entity.getContentEncoding();  
  20.                if (ceheader != null) {  
  21.                    HeaderElement[] codecs = ceheader.getElements();  
  22.                    for (int i = 0; i < codecs.length; i++) {  
  23.                        if (codecs[i].getName().equalsIgnoreCase("gzip")) {  
  24.                            response.setEntity(  
  25.                                    new GzipDecompressingEntity(response.getEntity()));   
  26.                            return;  
  27.                        }  
  28.                    }  
  29.                }  
  30.            }  
  31.              
  32.        });  
2、@RequestMapping 支持的自动注入方法参数类型, HttpServlet 对象,主要包括HttpServletRequest 、HttpServletResponse 和HttpSession 对象。 这些参数Spring 在调用处理器方法的时候会自动给它们赋值 ,所以当在处理器方法中需要使用到这些对象的时候,可以直接在方法上给定一个方法参数的申明,然后在方法体里面直接用就可以了。

3、httpclient直接伪造Cookie调用查询接口不行,udb可以要验证一系列的Cookie,可以从request对象拿到我们已经有UDB验证过的Cookie,然后设到请求头里,再调用查询接口

4、是Long不是long,要大写

5、只有根据日志我们能补回用户的数据才需要记录日志,别的不需要,比如一般的get请求,例如httpclient调用外部服务器查询接口,如果外部服务器挂掉了,我们也没有办法,这样就不需要记录日志,否则日志文件会很大

6、Java中String.format相当于C语言中的printf,占位符

7、拿到新的grunt项目先npm install,把依赖的库都装上,再build


完成任务:任务大厅每日登陆Y阅、每日阅读Y阅文章等三个任务







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值