Httpclient登录联通网上营业厅返回resultCode:9997问题。

最近公司项目要做一个把联通网上营业厅集成到我们网站来。也就是我需要用httpclient来模拟登录。于是去抓了一下包。
第一个请求(get)
https://uac.10010.com/portal/Service/checkRelease?callback=jQuery1720617107516456003_1511159960382&_=1511159961141
图片说明
第二个请求(get)
https://uac.10010.com/portal/Service/CheckNeedVerify?callback=jQuery17206564225944591909_1511159961003&userName=18602300879&pwdType=01&_=1511159993091
图片说明
第三个请求(get)发短信。
https://uac.10010.com/portal/Service/SendCkMSG?callback=jQuery17206564225944591909_1511159961004&req_time=1511160013454&mobile=18602356789&_=1511160013457
图片说明
这里调用了发短信的接口可以看到cookie里边有一个uacverifykey,但是我用的CookieStore cookieStore=new BasicCookieStore(); httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();然后打印出cookie,没有获取得到uacverifykey。只获取到了ckuuid这个数据。而没有uacverifykey

最后一步(登录)这个时候在cookie这也传了uacverifykey
https://uac.10010.com/portal/Service/MallLogin?callback=jQuery17206564225944591909_1511159961005&req_time=1511160027220&redirectURL=http%3A%2F%2Fwww.10010.com&userName=18602356789&password=123456&pwdType=01&productType=01&redirectType=01&rememberMe=1&verifyCKCode=726440&_=1511160027222
图片说明

执行这个登录之后就返回jQuery172007908107331762243_1511161316459({resultCode:9997}); 也不知道是什么问题。

跪求大家看看有没有研究过。。或则给我说说是什么地方出了问题了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Httpclient 请求weblogic的HttpServlet 返回的Response中Header不一致问题
大家好,开发过程中遇到个问题 ,我做的是CS项目,在客户端用Httpclient 请求weblogic的HttpServlet 返回的HttpServletResponse用了gzip压缩结果,但是在客户端接收时解压抛异常:java.util.zip.ZipException: Not in GZIP format server端设置了Header 并且压缩结果流 ``` response.setHeader("Content-Type", "text/html;charset=UTF-8"); response.setHeader("Content-Encoding", "gzip"); gzipstream = new GZIPOutputStream(output); ``` 客户端代码如下 CloseableHttpResponse response = defHttpclient.execute(httppost); ``` if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { InputStream inputStream = response.getEntity().getContent(); StringBuffer sb = new StringBuffer(); GZIPInputStream gzin = new GZIPInputStream(inputStream); InputStreamReader isr = new InputStreamReader(inputStream, charSet); String tempbf; long test3 = System.currentTimeMillis(); while ((tempbf = br.readLine()) != null) { sb.append(tempbf); } text_msg = sb.toString(); try { isr.close(); gzin.close(); inputStream.close(); } catch (Exception ex) { logger.error("class Request : when inputStream byteOut", ex); } } ``` 会在这一行报错 GZIPInputStream gzin = new GZIPInputStream(inputStream); 通过这个方法发现 Header headers[] = response.getAllHeaders(); 获得的Header中并没有服务端设置的setHeader("Content-Encoding", "gzip"); 请大佬们帮忙分析分析
HttpClient的循环发送请求,第一次成功,为什么第二次就Read timed out?
public String audits() throws Exception{ init(); /*String ids = "[" + condition.getIds() + "]"; String param="{" + "logId" + ":" + ids + "}";*/ String url = "http://192.168.1.220:8080/servlet/AuditServlet";//测试 PostMethod method = new PostMethod(url); HttpClient httpClient = new HttpClient(); //HttpClient httpClient = new HttpClient(new HttpClientParams(),new SimpleHttpConnectionManager(true)); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(600000); httpClient.getHttpConnectionManager().getParams().setSoTimeout(600000); try { int maxList = 5000; int lastIndex = maxList; Integer allTotal = 0; Integer allFaild = 0; Integer allSuccess = 0; List<String> lists = java.util.Arrays.asList(condition.getIds().split(",")); int count = lists.size(); List<List<String>> idList = new ArrayList<>(); for (int index = 0; index < count; ) { if (lastIndex >= count) { lastIndex = count; idList.add(lists.subList(index, lastIndex)); break; } else { idList.add(lists.subList(index, lastIndex)); index = lastIndex; // 设置下一批下标 lastIndex = index + (maxList - 1); } } if (CollectionUtils.isNotEmpty(idList)) { for (List<String> subList : idList) { String params="{" + "logId" + ":" + subList + "}"; System.out.println("请求接口参数:" + params); //循环发送请求 RequestEntity entity = new StringRequestEntity(params,"application/json","GBK"); System.out.println(1); method.setRequestEntity(entity); System.out.println(2); httpClient.executeMethod(method); System.out.println("请求接口路径url:" + method.getURI().toString()); System.out.println(3); InputStream in = method.getResponseBodyAsStream(); //下面将stream转换为String StringBuffer sb = new StringBuffer(); InputStreamReader isr = new InputStreamReader(in, "GBK"); char[] b = new char[4096]; for(int n; (n = isr.read(b)) != -1;) { sb.append(new String(b, 0, n)); } String returnStr = sb.toString(); System.out.println("返回接口参数:" + returnStr); JSONObject jasonObject = JSONObject.fromObject(returnStr); Map map = (Map)jasonObject; Object total = map.get("total"); Object faild = map.get("faild"); Object success = map.get("success"); allTotal = allTotal + Integer.valueOf(total.toString()); allFaild = allFaild + Integer.valueOf(faild.toString()); allSuccess = allSuccess + Integer.valueOf(success.toString()); } } String totals = allTotal.toString(); String failds = allFaild.toString(); String successs = allSuccess.toString(); condition.setTotal(totals); condition.setFaild(failds); condition.setSuccess(successs); return "index"; } catch (Exception e) { e.printStackTrace(); throw e; } finally { method.releaseConnection(); } } 第一次返回显示是成功的![图片说明](https://img-ask.csdn.net/upload/201912/25/1577256421_630516.png) 第二次就![图片说明](https://img-ask.csdn.net/upload/201912/25/1577256497_930744.png)
java.net.ConnectException: Connection refused: connect
昨天遇到了这个错,到现在没解决,求大佬帮助 1.服务器安装了一个8082的项目,网页访问服务器ip:8082没有任何问题 2.本地装了个node,启动了一个前端项目 localhost:3000,后端接口配的就是http://服务器ip:8082 然后本地掉服务器接口就一直报 java.net.ConnectException: Connection refused: connect, 3.前端是通过jsonp掉的接口 之前都是好的,请问怎么解决啊 spring boot 项目 服务器windows的,防火墙是关闭的,端口也没占用 错误信息 ``` java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:432) at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) at sun.net.www.http.HttpClient.<init>(HttpClient.java:211) at sun.net.www.http.HttpClient.New(HttpClient.java:308) at sun.net.www.http.HttpClient.New(HttpClient.java:326) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1167) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1103) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:997) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:931) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1281) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1256) at com.sunline.utils.HttpUtil.httpRequest(HttpUtil.java:62) at com.sunline.utils.HttpUtil.httpRequest(HttpUtil.java:30) at com.sunline.web.controller.XlrLoginController.oauthLogin(XlrLoginController.java:134) at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:158) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:126) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:111) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:209) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) ```
openfeign里面配置httpclient出错。
因为现在需要使用get方式传递对象参数,所以尝试在openfeign里面配置httpclient。 配置代码如下: 在yml文件里面增加了配置信息 ``` feign: httpclient: enabled: true ``` 在pom.xml文件中引入的依赖: ``` <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.3</version> </dependency> <!-- 使用Apache HttpClient替换Feign原生httpclient --> <dependency> <groupId>com.netflix.feign</groupId> <artifactId>feign-httpclient</artifactId> <version>8.16.1</version> </dependency> ``` 配置好以后尝试使用get方式传递对象参数。 服务提供端代码: ``` @GetMapping(value = "testAddRole1",consumes = "application/json") public JsonResult addTest1(@RequestBody Role role){ roleService.addRole(role); return JsonResult.getInstant(ReturnCodeEnum.SUCCESS); } ``` 服务调用接口为: ``` @GetMapping(value = "/testAddRole1",consumes = "application/json") JsonResult testAddRole1(@RequestBody Role role); ``` 现在在尝试调用接口后发现服务提供方可以接受到参数并且能够写到数据库中,但是在服务调用方拿不到正确的返回值并且会报错,错误如下: ``` Caused by: java.lang.NoSuchMethodError: feign.Response.create(ILjava/lang/String;Ljava/util/Map;Lfeign/Response$Body;)Lfeign/Response; ``` 查看源码得知,openfeign在接受返回值时调用的不是httpclient的feign-core包的代码而是调用的本身的feign-core的代码,而本身的feign-core包中的Response类没有create方法。 得知原因后我将httpclient的依赖在pom文件中的位置上移,使openfeign优先调用httpclient的feign-core包的代码,结果在启动项目时就报错,报错信息为: ``` org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'test1Controller' defined in file [D:\workspace\basic\openfeign\target\classes\cn\cloudscope\openfeignTest\Test1\controller\Test1Controller.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.cloudscope.openfeignTest.Test1.service.Test1Service': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignRetryer' defined in org.springframework.cloud.openfeign.FeignClientsConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [feign.Retryer]: Factory method 'feignRetryer' threw exception; nested exception is java.lang.NoSuchFieldError: NEVER_RETRY ``` 查看原因得知是两个feign-core包中的Retryer接口不一致导致的,求来个大神帮忙解决一下,或者怎么调整jar包的版本去解决这个问题。openfeign的feign-core版本为10.1.0 httpclient的版本为8.16.1
HttpClient 模拟登录 Cookie问题
问题描述:向登录地址发起POST请求,提交登录验证信息,提示登录成功后发起另一个请求,返回提示“未登陆,请重新登陆”。 我这里用了同一个 HttpClient 实例,不知为何? DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPost = new HttpPos("http://members.dota2.com.cn/dologin"); java.util.List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("username", "username")); nvps.add(new BasicNameValuePair("passwd", "password")); nvps.add(new BasicNameValuePair("rand", yzm)); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); HttpResponse response = httpclient.execute(httpPost); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == 200) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpEntity entity = response.getEntity(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String result = EntityUtils.toString(entity); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JSONObject json = JSONObject.fromObject(result); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("登录系统返回信息:"+json.toString()); } HttpPost httpPost = new HttpPost("http://event21.dota2.com.cn/dota2/activation/vipTester!contend.action"); java.util.List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("r", String.valueOf(Math.random()))); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); HttpResponse response = httpclient.execute(httpPost); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == 200) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpEntity entity = response.getEntity(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String result = EntityUtils.toString(entity); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JSONObject json = JSONObject.fromObject(result); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("RETURN DATA : " + json.toString()); }
httpclient 模拟登录邮箱
httpclient 模拟登录邮箱 登录邮箱 private static String USERNAME = "111111"; private static String PASSWORD = "222222"; private static String LOGINURL = "https://mail.qq.com"; public static void main(String[] args) { HttpClient httpClient = new HttpClient(); PostMethod authpost = new PostMethod(LOGINURL); NameValuePair user = new NameValuePair("user",USERNAME); NameValuePair pwd = new NameValuePair("password",PASSWORD); NameValuePair username = new NameValuePair("username",USERNAME + "@qq.com"); authpost.setRequestBody(new NameValuePair[]{user,pwd,username}); int status = httpClient.executeMethod(authpost); System.out.println(authpost.getResponseBodyAsString()); System.out.println(status); 为什么登录不上去,是因为没有设置登录页面参数吗?
httpClient 3如何session会话保持?
问题场景: 通过httpClient请求同一门户的接口地址,因为登录后和未登录的时候返回的数据不一样。所以当用户在门户上登录的情况下,访问接口返回的数据也应该是要登录口的数据。现在返回的都是未登录的情况。‘请问大神们此问题如何解决。 代码如下: String url = "http://192.168.41.56/portal/480/home/wap/xqy/ljjk/dbjqbf/index.jsp"; String result = ""; HttpClient client = new HttpClient(); //client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); HttpConnectionManagerParams managerParams = client.getHttpConnectionManager().getParams(); // 设置连接超时时间(单位毫秒) managerParams.setConnectionTimeout(500); managerParams.setSoTimeout(5000); GetMethod getMethod=new GetMethod(); URI base = new URI(url,false); getMethod.setURI(new URI(base,"",false)); int resultCode = client.executeMethod(getMethod); if(resultCode == 200 ) { byte[] body=getMethod.getResponseBody(); if(body!=null && body.length>0){ result=new String(body,"UTF-8"); System.out.println(result); }else{ System.out.println(" 无返回值 url ="+url); } }else{ System.out.println(" HTTP 返回异常 url ="+url +", resultCode= "+ resultCode); } getMethod.releaseConnection();
httpclient提交一个请求返回的都是200的状态码,如何判断怎么是成功的怎么是失败的
httpclient提交一个用于登录的请求,但是返回的都是200的状态码,如何判断怎么是成功的怎么是失败的呢?
测试报错,Connection refused: connect,求解?
代码: ``` public class ItfTest { /** * @param args */ public static void main(String[] args) { try { String out = testbiz(); System.out.println(out); } catch (IOException e) { e.printStackTrace(); } } public static String testbiz() throws HttpException, IOException { HttpClient httpClient = new HttpClient(); PostMethod post = new PostMethod( "http://localhost:8001/itf/OI_AddSaleByParameter"); // PostMethod post = new PostMethod( "https://rryx.sinovatech.com/itf/OI_QueryEShopOrder"); post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); String key = "123321abc"; String channel="ch_shenxun"; Map<String, Object> req = new HashMap<>(); String instr ="{\"body\": \"{\\\"startTime\\\":\\\"2019-01-01 14:43:19\\\",\\\"endTime\\\":\\\"2019-01-12 15:14:42\\\",\\\"phone\\\":\\\"18309858042\\\"}\",\"head\": {} }"; /* String instr ="6351"; req.put("loginCode",instr);*/ Map<String, Object> header = new HashMap<>(); header.put("appId", channel); header.put("tid", UUID.randomUUID().toString()); header.put("timestamp", System.currentTimeMillis()); header.put("ver", "1.0"); Map<String, Object> reMap = new HashMap<>(); reMap.put("header", header); reMap.put("req", req); req.put("saleName","123"); req.put("goodIds","ff8080815e562c4d015e6103956700b6"); req.put("orderValue","1"); req.put("createName","管理员"); System.out.println(JSONObject.toJSON(reMap)); String reqdata = JSONObject.toJSONString(reMap); String sign = DigestUtils.md5Hex(reqdata + key); NameValuePair[] param = { new NameValuePair("sign", sign), new NameValuePair("reqdata", reqdata) }; post.setRequestBody(param); int result = httpClient.executeMethod(post); System.out.println("返回结果=" + result); InputStream in = post.getResponseBodyAsStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder sb = new StringBuilder(); String line = reader.readLine(); while (line != null) { sb.append(line); line = reader.readLine(); } reader.close(); return sb.toString(); } } //以上代码传参测试,但是运行后报错 java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.<init>(Socket.java:434) at java.net.Socket.<init>(Socket.java:286) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122) at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at com.sinovatech.test.ItfTest.testbiz(ItfTest.java:95) at com.sinovatech.test.ItfTest.main(ItfTest.java:52) 求大神指点 ```
HttpClient调用接口返回json
java的httpclient发送post请求传入 data , data_digest , msg_type, company_id ,四个参数 调用接口一直返回S02,无法返回我想要的json数据怎么办?
使用angular和mongodb做web开发,想问怎么传数组形式的数据回去后台的mogodb数据库?
如果我mogodb定义的数据类型是string的话, 然后在ts文件中定义的类 YueCuisine的其中数据的属性均为string,比如说: ``` export class YueCuisine { constructor( public id: string, public name: string, public intro: string, } ``` 这样服务中services.ts的更新数据的函数这样写: ``` updatecai(cai1: YueCuisine): Observable<YueCuisine> { return this.httpClient.put<YueCuisine>(this.yueUrl, cai1); } ``` 然后组件中component.ts的函数这样写: ``` save(): void { this.yueService.updatecai(this.yue) .subscribe(() => this.goBack()); } ``` 然后在html的某个button里调用这个函数,去更新后台数据是完全没问题的。 但是我把mongodb中的某项数据定义成“array”属性,然后在angular的类中声明变成: ``` public intro:Array<string> ``` 而不更改那些函数的写法,就不能成功像后台传数据了。请问要怎么做?
HttpClient登录后,使用默认浏览器打开页面是登录的状态
大家好,现在有个问题,httpclient可以登录,登录成功后怎么和浏览器进行交互,让浏览器是登录的状态呢?不用从新登录。换句话说就是让浏览器识别httpclient的登录信息? 不知道我这个思路对不对?有大神做过相关的工作么?谢了
jemter接口返回org.apache.http.NoHttpResponseException: xxxxxxxxx failed to respond,要怎么解决?
对接口简单进行压测,线程数100,时间20秒,没有勾选keepAlive,修改httpclient4.idletimeout=20000,也取消了注释 ![图片说明](https://img-ask.csdn.net/upload/201911/22/1574406694_931198.png)
用httpclient调用google elevation api时返回状态码为405
如题:代码如下,为神马返回状态码为405呢?有哪位大神用过google elevation api,通过浏览器直接访问接口正常,用httpclient访问在不设置代理前直接连接超时,设置代理后后返回405的状态码。 ``` public static void test2(){ try { SSLContext sslcontext = SSLContexts.custom() .loadTrustMaterial(new File("C:\\Program Files\\Java\\jdk1.7.0_13\\jre\\lib\\security\\cacerts"), "changeit".toCharArray(), new TrustSelfSignedStrategy()) .build(); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( sslcontext, new String[] { "TLSv1" }, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); CloseableHttpClient httpclient = HttpClients.custom() .setSSLSocketFactory(sslsf) .build(); HttpHost proxy = new HttpHost("220.255.2.153"); //设置google代理服务器 RequestConfig config = RequestConfig.custom().setProxy(proxy).build(); HttpGet httpget = new HttpGet("https://maps.googleapis.com/maps/api/elevation/json?locations=39.938576,116.42188&key=YOUR_KEY"); httpget.setConfig(config); System.out.println("Executing request " + httpget.getRequestLine()); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); System.out.println("----------------------------------------"); System.out.println(response.getStatusLine().getStatusCode()); EntityUtils.consume(entity); } catch (Exception e) { e.printStackTrace(); } } ```
JAVA POST登录异常问题?
网上找的HTTP登录代码,登录后返回能200,但是不用用户名密码也返回200,且用Cookie[] cookies = httpClient.getState().getCookies(); StringBuffer tmpcookies = new StringBuffer(); for (Cookie c : cookies) { tmpcookies.append(c.toString() + ";"); System.out.println("cookies = "+c.toString()); } 能取到Cookies,这个搞不懂 登录成功后跳到另一个网页,但是用System.out.println("ResponseBody:\n" + stringBuffer.toString());返回如下: ``` <html> <head><title></title> <SCRIPT LANGUAGE="JavaScript"> var currentWindow = window; if(currentWindow != null){ currentWindow.top.location = "/NMMP/jsp/login.jsp"; } </SCRIPT> </head> ``` 感觉跳转时少了东西,所以跳转后的网页不对,请各们大神帮分析下,或者给个思路,本人不是搞程序的,只是想做一个来应对自己的重复工作,完整代码如下:本人无C币,如果有兴趣帮我做可商量 ``` import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; /** * * @ClassName: HttpLogin * @Description: java通过httpclient获取cookie模拟登录 * @author zeze * @date 2015年11月10日 下午4:18:08 * */ public class HttpLogin { public static void main(String[] args) { // 登陆 Url String loginUrl = "http://10.154.13.82:7011/NMMP/jsp/login.jsp"; // 需登陆后访问的 Url String dataUrl = "http://10.154.13.82:7011/NMMP/wyMainAction!init.ilf"; //http://10.154.13.82:7011/NMMP//jsp/wyService/mytasklist.jsp HttpClient httpClient = new HttpClient(); // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式 PostMethod postMethod = new PostMethod(loginUrl); // 设置登陆时要求的信息,用户名和密码 NameValuePair[] data = { new NameValuePair("useraccount", ""), new NameValuePair("password", "Hn_yd45") }; postMethod.setRequestBody(data); try { // 设置 HttpClient 接收 Cookie,用与浏览器一样的策略 httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); int statusCode=httpClient.executeMethod(postMethod); // 获得登陆后的 Cookie Cookie[] cookies = httpClient.getState().getCookies(); StringBuffer tmpcookies = new StringBuffer(); for (Cookie c : cookies) { tmpcookies.append(c.toString() + ";"); System.out.println("cookies = "+c.toString()); } System.out.println(statusCode); if(statusCode==200){//重定向到新的URL System.out.println("模拟登录成功"); // 进行登陆后的操作 GetMethod getMethod = new GetMethod(dataUrl); // 每次访问需授权的网址时需带上前面的 cookie 作为通行证 // getMethod.setRequestHeader("cookie", tmpcookies.toString()); // 你还可以通过 PostMethod/GetMethod 设置更多的请求后数据 // 例如,referer 从哪里来的,UA 像搜索引擎都会表名自己是谁,无良搜索引擎除外 // postMethod.setRequestHeader("Referer", "http://passport.mop.com/"); getMethod.setRequestHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); getMethod.setRequestHeader("Referer","http://10.154.13.82:7011/NMMP/login.ilf"); getMethod.setRequestHeader("Accept-Encoding","gzip, deflate"); getMethod.setRequestHeader("Accept-Language","zh-CN,zh;q=0.9"); getMethod.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" ); httpClient.executeMethod(getMethod); statusCode=httpClient.executeMethod(getMethod); System.out.println("模拟登录成功"+statusCode); // 打印出返回数据,检验一下是否成功 // String text = getMethod.getResponseBodyAsString(); InputStream inputStream = getMethod.getResponseBodyAsStream(); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); StringBuffer stringBuffer = new StringBuffer(); String str= ""; while((str = br.readLine()) != null){ stringBuffer .append(str ); } System.out.println("ResponseBody:\n" + stringBuffer.toString()); HttpRequestProxy hrp = new HttpRequestProxy(); Map date = new HashMap(); date.put("jyidApplet", "1"); date.put("codeNumApplet", "1"); date.put("jymxIdApplet", "447"); date.put("patientIdApplet", "1118"); String str1 = hrp.doRequest(dataUrl,date, null, null); System.out.println("sd"+str1); } else { System.out.println("登录失败"); } } catch (Exception e) { e.printStackTrace(); } } } ``` 登录网页源码如下: ``` <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>综合管理系统</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <style type="text/css"> *{ margin:auto; } html,body{ overflow:hidden; width:100%; height:100%; margin:auto; } body{ background:url(/NMMP/common-skins/maintain/images/login_bg_1.0.gif); } #login_panel{ background-image:url(/NMMP/common-skins/maintain/images/login_panel_bg_1.0.png); background-repeat:repeat-x; height:640px; width:100%; text-align:center; position:relative; } #login_input{ background-image:url(/NMMP/common-skins/maintain/images/login_input_1.0.png); background-repeat:no-repeat; width:668px; height:403px; position:relative; } #useraccount{ border:none; position:absolute; left:392px; top:149px; height:24px; width:136px; background-color:#99deff; } #password{ border:none; position:absolute; left:392px; top:183px; height:24px; width:136px; background-color:#99deff; } #login_botton{ position:absolute; left:537px; _left:538px; top:147px; } #message{ position:absolute; left:348px; top:218px; color:#F00; font-size:14px; font-weight:bold; } #technical{ position:absolute; left:375px; top:258px; text-align:left; color:#CCC; font-size:12px; line-height:30px; } #copyright{ position:absolute; bottom:65px; right:0px; color:#CCC; font-size:12px; text-align:right; line-height:20px; } </style> <!--[if IE 6]> <script language="javascript" type="text/javascript" src="/NMMP/common-skins/default/jslib/DD_belatedPNG.js"> </script> <script language="javascript" type="text/javascript"> DD_belatedPNG.fix('#login_panel'); DD_belatedPNG.fix('#login_input'); </script> <![endif]--> </head> <body windowc_onresizez="true"> <div id="login_panel"> <div id="login_input" style="top: 110.5px;"> <form name="form1" action="/NMMP/CtrlUser.action?action=login&amp;surl=jsp/home/main.jsp&amp;furl=jsp/login.jsp" method="post" 360chrome_form_autofill="2"> <input name="useraccount" id="useraccount" style="background-color: rgb(250, 255, 189);" required="true" type="text"> <input name="password" id="password" style="background-color: rgb(250, 255, 189);" required="true" type="password"> <input id="login_botton" type="image" src="/NMMP/common-skins/maintain/images/login_botton.png"> <div id="message"> </div> <!-- div id="technical"><a style="color:orange" href="javascript:void(0)" onclick="resetpwd();">密码重置</a></div--> <div id="copyright">版权所有:</div> </form> </div> </div> <script language="javascript" type="text/javascript"> document.getElementById("login_input").style.top=(document.body.clientHeight-403)/2+"px"; function resetpwd(){ var url = "/NMMP/resetpwdAction.ilf"; window.location.href=url; } </script> </body></html> ```
HttpClient请求返回结果对象HttpEntity处理
HttpClient请求返回结果对象HttpEntity处理转成字符串一串![图片说明](https://img-ask.csdn.net/upload/201706/20/1497950405_70131.png)
使用CXF发布Rest服务 出现read time out错误
CXF版本:2.3.0 现象:偶尔出现连接超时,但不是必现,不知道是否有高手遇到过类似的错误 部分异常信息: ``` [1127 10:55:38 480 WARN ] [http-bio-9095-exec-9] cxf.phase.PhaseInterceptorChain - Interceptor for {http://localhost:9091/test/ws}WebClient has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Could not send Message. at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:247) at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:616) at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:596) at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:324) at org.apache.cxf.jaxrs.client.WebClient.post(WebClient.java:360) at com.neusoft.acorn.apps.terminal.application.internal.ExamEndSignServiceImpl.saveExamEndSignInfo(ExamEndSignServiceImpl.java:34) at com.neusoft.acorn.protocol.terminal.ExamEndSignSubmitData.saveExamEndSignInfo(ExamEndSignSubmitData.java:1208) at com.neusoft.acorn.protocol.terminal.FunctionSubmitALLCheckData.getReturnXmlValue(FunctionSubmitALLCheckData.java:102) at com.neusoft.acorn.protocol.terminal.TRMDataExchange.dmClient(TRMDataExchange.java:150) at com.neusoft.acorn.protocol.terminal.TRMDataExchange.doGetPost(TRMDataExchange.java:86) at com.neusoft.acorn.protocol.terminal.TRMDataExchange.doPost(TRMDataExchange.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1136) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking http://localhost:9091/test/ws/dailyTestAssemble/putExamEndSign.xml: Read timed out at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1995) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1980) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:662) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) ... 37 more Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:152) at java.net.SocketInputStream.read(SocketInputStream.java:122) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) at java.io.BufferedInputStream.read(BufferedInputStream.java:334) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:690) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1324) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2102) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2071) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1925) ... 40 more ```
springboot加了个redis依赖后启动运行日志就少了?
我的pom依赖 ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.jeecg</groupId> <artifactId>bgApi</artifactId> <packaging>jar</packaging> <name>bgApi</name> <version>1.0.0</version> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> <tomcat.version>8.5.27</tomcat.version> <servlet-api.version>3.0.1</servlet-api.version> </properties> <dependencies> <!-- redis 依赖--> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </dependency> <!-- redis --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> </dependency> <dependency> <groupId>cn.jpush.api</groupId> <artifactId>jiguang-common</artifactId> <version>1.0.8</version> </dependency> <dependency> <groupId>net.coobird</groupId> <artifactId>thumbnailator</artifactId> <version>0.4.6</version> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>4.1.18</version> </dependency> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>3.3.3</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>3.3.3</version> </dependency> <dependency> <groupId>com.jhlabs</groupId> <artifactId>filters</artifactId> <version>2.0.235-1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.1</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.6</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.3</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpmime</artifactId> <version>4.5.1</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.4.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-base</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-web</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-annotation</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> <version>5.1.46</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- 这个需要为 true 热部署才有效 --> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j</artifactId> <version>1.3.8.RELEASE</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.0.1</version> </dependency> </dependencies> <build> <finalName>bgApi</finalName> <defaultGoal>install</defaultGoal> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build> </project> ``` 没加redis依赖的时候sql语句都可以打印,现在没有了,是怎么回事啊
使用Closeablehttpclient.execute,ubuntu下出现以下证书问题
错误log javax.net.ssl.SSLException: Certificate for <> doesn't match any of the subject alternative names: [] at org.apache.http.conn.ssl.DefaultHostnameVerifier.matchDNSName(DefaultHostnameVerifier.java:158) ~[httpclient-4.5.jar:4.5] at org.apache.http.conn.ssl.DefaultHostnameVerifier.verify(DefaultHostnameVerifier.java:109) ~[httpclient-4.5.jar:4.5] at org.apache.http.conn.ssl.DefaultHostnameVerifier.verify(DefaultHostnameVerifier.java:87) ~[httpclient-4.5.jar:4.5] at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:461) [httpclient-4.5.jar:4.5] at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:395) [httpclient-4.5.jar:4.5] at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353) [httpclient-4.5.jar:4.5] at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134) [httpclient-4.5.jar:4.5] at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353) [httpclient-4.5.jar:4.5] at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380) [httpclient-4.5.jar:4.5] at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) [httpclient-4.5.jar:4.5] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) [httpclient-4.5.jar:4.5] at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) [httpclient-4.5.jar:4.5] at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) [httpclient-4.5.jar:4.5] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) [httpclient-4.5.jar:4.5] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) [httpclient-4.5.jar:4.5] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) [httpclient-4.5.jar:4.5] 代码段为: CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(url); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, Consts.UTF_8); httpPost.setEntity(entity); CloseableHttpResponse resp=null; try { resp = httpClient.execute(httpPost); HttpEntity respEntity = resp.getEntity(); String body = EntityUtils.toString(respEntity, charset); 在执行到 resp = httpClient.execute(httpPost);在ubuntu下开发就会抛出异常,而在windows下开发则没有此类错误,请教大神这是什么问题。
相见恨晚的超实用网站
搞学习 知乎:www.zhihu.com 简答题:http://www.jiandati.com/ 网易公开课:https://open.163.com/ted/ 网易云课堂:https://study.163.com/ 中国大学MOOC:www.icourse163.org 网易云课堂:study.163.com 哔哩哔哩弹幕网:www.bilibili.com 我要自学网:www.51zxw
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
引言 本文主要是记录一下面试字节跳动的经历。 三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时
开源一个功能完整的SpringBoot项目框架
福利来了,给大家带来一个福利。 最近想了解一下有关Spring Boot的开源项目,看了很多开源的框架,大多是一些demo或者是一个未成形的项目,基本功能都不完整,尤其是用户权限和菜单方面几乎没有完整的。 想到我之前做的框架,里面通用模块有:用户模块,权限模块,菜单模块,功能模块也齐全了,每一个功能都是完整的。 打算把这个框架分享出来,供大家使用和学习。 为什么用框架? 框架可以学习整体
源码阅读(19):Java中主要的Map结构——HashMap容器(下1)
(接上文《源码阅读(18):Java中主要的Map结构——HashMap容器(中)》) 3.4.4、HashMap添加K-V键值对(红黑树方式) 上文我们介绍了在HashMap中table数组的某个索引位上,基于单向链表添加新的K-V键值对对象(HashMap.Node&lt;K, V&gt;类的实例),但是我们同时知道在某些的场景下,HashMap中table数据的某个索引位上,数据是按照红黑树
c++制作的植物大战僵尸,开源,一代二代结合游戏
    此游戏全部由本人自己制作完成。游戏大部分的素材来源于原版游戏素材,少部分搜集于网络,以及自己制作。 此游戏为同人游戏而且仅供学习交流使用,任何人未经授权,不得对本游戏进行更改、盗用等,否则后果自负。 目前有六种僵尸和六种植物,植物和僵尸的动画都是本人做的。qq:2117610943 开源代码下载 提取码:3vzm 点击下载--&gt; 11月28日 新增四种植物 统一植物画风,全部修
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
Python——画一棵漂亮的樱花树(不同种樱花+玫瑰+圣诞树喔)
最近翻到一篇知乎,上面有不少用Python(大多是turtle库)绘制的树图,感觉很漂亮,我整理了一下,挑了一些我觉得不错的代码分享给大家(这些我都测试过,确实可以生成喔~) one 樱花树 动态生成樱花 效果图(这个是动态的): 实现代码 import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
深度学习图像算法在内容安全领域的应用
互联网给人们生活带来便利的同时也隐含了大量不良信息,防范互联网平台有害内容传播引起了多方面的高度关注。本次演讲从技术层面分享网易易盾在内容安全领域的算法实践经验,包括深度学习图
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
Python 编程实用技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法,并会持续更新。
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
"狗屁不通文章生成器"登顶GitHub热榜,分分钟写出万字形式主义大作
GitHub 被誉为全球最大的同性交友网站,……,陪伴我们已经走过 10+ 年时间,它托管了大量的软件代码,同时也承载了程序员无尽的欢乐。 万字申请,废话报告,魔幻形式主义大作怎么写?兄dei,狗屁不通文章生成器了解一下。这个富有灵魂的项目名吸引了众人的目光。项目仅仅诞生一周,便冲上了GitHub趋势榜榜首(Js中文网 -前端进阶资源教程)、是榜首哦
推荐几款比较实用的工具,网站
1.盘百度PanDownload 这个云盘工具是免费的,可以进行资源搜索,提速(偶尔会抽风????) 不要去某站买付费的???? PanDownload下载地址 2.BeJSON 这是一款拥有各种在线工具的网站,推荐它的主要原因是网站简洁,功能齐全,广告相比其他广告好太多了 bejson网站 3.二维码美化 这个网站的二维码美化很好看,网站界面也很...
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
相关热词 c#选择结构应用基本算法 c# 收到udp包后回包 c#oracle 头文件 c# 序列化对象 自定义 c# tcp 心跳 c# ice连接服务端 c# md5 解密 c# 文字导航控件 c#注册dll文件 c#安装.net
立即提问