1、httpclient出现乱码可能是由于发过来的东西是压缩过的,所以解压一下就行了
- httpclient.addRequestInterceptor(new HttpRequestInterceptor() {
- public void process(
- final HttpRequest request,
- final HttpContext context) throws HttpException, IOException {
- if (!request.containsHeader("Accept-Encoding")) {
- request.addHeader("Accept-Encoding", "gzip");
- }
- }
- });
- httpclient.addResponseInterceptor(new HttpResponseInterceptor() {
- public void process(
- final HttpResponse response,
- final HttpContext context) throws HttpException, IOException {
- HttpEntity entity = response.getEntity();
- Header ceheader = entity.getContentEncoding();
- if (ceheader != null) {
- HeaderElement[] codecs = ceheader.getElements();
- for (int i = 0; i < codecs.length; i++) {
- if (codecs[i].getName().equalsIgnoreCase("gzip")) {
- response.setEntity(
- new GzipDecompressingEntity(response.getEntity()));
- return;
- }
- }
- }
- }
- });
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阅文章等三个任务