如何用RestTemplate同时传递一个Java对象和基本类型的参数?

我用RestTemplate想两个参数,一个是自己写的Java类,一个是基本类型

请求的Controller

    @RequestMapping("/buy")
    public int buy(@RequestBody GoodsDetail goodsDetail,Integer buyCount){
        goodsDetail.setRemaining(goodsDetail.getRemaining() - buyCount);
        int num = goodsDetailMapper.updateByPrimaryKey(goodsDetail);
        return num;
    }
  • 用getForObject:

        Map<String,Object> map = new HashMap<>();
        map.put("goodsDetail",goodsDetail);
        map.put("buyCount",buyCount);
        int num = restTemplate.getForObject("http://localhost:8088/shop-buy/buy?goodsDetail={goodsDetail}&buyCount={buyCount}", int.class, map);
    

    报400 null图片说明

  • 用postForObject:

        MultiValueMap<String,Object> multiValueMap = new LinkedMultiValueMap<>();
        multiValueMap.add("goodsDetail",goodsDetail);
        multiValueMap.add("buyCount",buyCount);
        int num = restTemplate.postForObject("http://localhost:8088/shop-buy/buy", multiValueMap, int.class);

报415 null 图片说明

求救,要疯掉了!

2个回答

@RequestParam 或者将这两个封装到一个实体类

qq_34444616
咖啡加冰66 回复我的小名是于晏: 你可以了解一下请求体类型
10 个月之前 回复
shuaihang123
我的小名是于晏 其实我可以不用这样传参数的,但是遇到了就想跟大家一起研究一下
10 个月之前 回复
shuaihang123
我的小名是于晏 @RequestParam试过了,不管用;但是封装到一起的话就感觉很不舒服。。。
10 个月之前 回复
@RequestMapping("/buy/{buyCount}")
    public int buy(@RequestBody GoodsDetail goodsDetail,@PathParam ("buyCount") Integer buyCount){
        goodsDetail.setRemaining(goodsDetail.getRemaining() - buyCount);
        int num = goodsDetailMapper.updateByPrimaryKey(goodsDetail);
        return num;
    }
shuaihang123
我的小名是于晏 回复我的小名是于晏: 这个我也试过了,也没用
9 个月之前 回复
shuaihang123
我的小名是于晏 感谢回复!但是
9 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
restTemplate能否传递list集合?
如下,我想要直接传递list过去 然后在客户端处理list ``` RestTemplate restTemplate = new RestTemplate(); for (ScanFamily scanFamily : scanFamilyList) { String requestWebUrl = url; //获取档案列表 List<ArchiveFile> archiveFileList = this.archiveFileManager.searchList(scanFamily.getFamilyNo()); //TODO 直接传递list MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<String, Object>(); paramMap.add("archiveFileList",archiveFileList); String s = restTemplate.postForObject(requestWebUrl, paramMap, String.class); ``` 但是它会一直报错: ``` org.springframework.http.converter.HttpMessageNotWritableException: Could not write request: no suitable HttpMessageConverter found for request type [java.util.ArrayList] at org.springframework.http.converter.FormHttpMessageConverter.writePart(FormHttpMessageConverter.java:292) at org.springframework.http.converter.FormHttpMessageConverter.writeParts(FormHttpMessageConverter.java:252) at org.springframework.http.converter.FormHttpMessageConverter.writeMultipart(FormHttpMessageConverter.java:242) at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:194) at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:1) at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:588) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:436) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401) at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:279) ```
springframework使用restTemplate的postForObject的问题
在调用微博的accessToken的授权接口时,参数是加在uri后面,但使用的method是POST方式,那restTemplate的postForObject方法时该如何写,我的请求都是400 Bad Request. 使用的是restTemplate.postForObject(url, null, String.class, params)方法,那么参数都应该如何封装,最好有案列,多谢各位大神!
Java RestTemplate问题
restTemplate.exchange(url , httpMethod.post , new httpEntity( ) , String.class , params ); 其中 params 参数 为 传递的参数,为什么到 那边 参数会没有呢?
Java项目开启https双向认证,服务中使用restTemplate发出的请求,怎么能访问该服务?
使用https的单向认证,通过配置下面代码能实现restTemplate的访问 ``` @Primary @Bean public RestTemplate restTemplate() { return new RestTemplate(generateHttpsRequestFactory()); } public HttpComponentsClientHttpRequestFactory generateHttpsRequestFactory() { try { TrustStrategy acceptingTrustStrategy = (x509Certificates, authType) -> true; SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier()); HttpClientBuilder httpClientBuilder = HttpClients.custom(); httpClientBuilder.setSSLSocketFactory(connectionSocketFactory); CloseableHttpClient httpClient = httpClientBuilder.build(); HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); factory.setHttpClient(httpClient); factory.setConnectTimeout(10 * 1000); factory.setReadTimeout(30 * 1000); return factory; } catch (Exception e) { throw new RuntimeException("创建HttpsRestTemplate失败", e); } } ``` 如果在tomcat中开启双向https认证,访问报错 ``` org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://127.0.0.1:9082/portal/oauth/token": Received fatal alert: bad_certificate; nested exception is javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:666) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.client.RestTemplate$$FastClassBySpringCGLIB$$aa4e9ed0.invoke(<generated>) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.cloud.netflix.metrics.RestTemplateUrlTemplateCapturingAspect.captureUrlTemplate(RestTemplateUrlTemplateCapturingAspect.java:33) ~[spring-cloud-netflix-core-1.3.6.RELEASE.jar:1.3.6.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_192] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_192] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_192] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_192] at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) ~[spring-aop-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.client.RestTemplate$$EnhancerBySpringCGLIB$$33760eb2.exchange(<generated>) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at com.knowind.service.impl.AuthenticationService.applyToken(AuthenticationService.java:90) ~[classes/:0.0.1-SNAPSHOT] at com.knowind.service.impl.AuthenticationService.login(AuthenticationService.java:49) ~[classes/:0.0.1-SNAPSHOT] at com.knowind.controller.AuthenticationController.login(AuthenticationController.java:75) ~[classes/:0.0.1-SNAPSHOT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_192] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_192] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_192] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_192] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) ~[servlet-api.jar:na] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.8.RELEASE.jar:4.3.8.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-websocket.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at com.knowind.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:30) ~[classes/:0.0.1-SNAPSHOT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110) ~[spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:208) ~[spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) ~[spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:167) ~[spring-session-1.3.0.RELEASE.jar:na] at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) ~[spring-session-1.3.0.RELEASE.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106) ~[spring-boot-actuator-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:108) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.45] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.45] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:8.5.45] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.45] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:645) [catalina.jar:8.5.45] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [catalina.jar:8.5.45] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.45] at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678) [catalina.jar:8.5.45] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.45] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [catalina.jar:8.5.45] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) [tomcat-coyote.jar:8.5.45] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.45] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810) [tomcat-coyote.jar:8.5.45] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) [tomcat-coyote.jar:8.5.45] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.45] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_192] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_192] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.45] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_192] Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_192] at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) ~[na:1.8.0_192] at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2020) ~[na:1.8.0_192] at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1127) ~[na:1.8.0_192] at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367) ~[na:1.8.0_192] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395) ~[na:1.8.0_192] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379) ~[na:1.8.0_192] at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.3.jar:4.5.3] at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:89) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:99) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.cloud.netflix.metrics.MetricsClientHttpRequestInterceptor.intercept(MetricsClientHttpRequestInterceptor.java:64) ~[spring-cloud-netflix-core-1.3.6.RELEASE.jar:1.3.6.RELEASE] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:70) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] ... 110 common frames omitted ```
java 使用RestTemplate.getForObject() 方法请求PHP接口
java 使用RestTemplate.getForObject() 方法请求PHP接口返回 ![图片说明](https://img-ask.csdn.net/upload/201804/09/1523265200_880886.png) 用浏览器、postman请求,返回正常json数据,什么问题?
如何使用RestTemplate的postForEntity方法发送带有xml类型的数据,xml类型数据放在body体里
如以下xml数据,要求放在body的请求体里 ``` <tsRequest> <credentials name="" password=""> <site contentUrl="" /> </credentials> </tsRequest> ```
使用RestTemplate 访问Flink程序,怎么运行jar包?
我的Flink程序需要从args里读取一个json格式的参数,用RestTemplate 怎么发送json格式,在Flink程序里一直不能收到,怎么传参?
restTemplate发送post请求时报错
这个是我发送请求的代码部分逻辑 ``` public String getPortInfo(String hostName){ PortInfo portInfo =new PortInfo(); MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>(); portInfo.setHostName(hostName); portInfo.setIp("8762"); paramMap.add("reqData", JSONObject.toJSONString(portInfo)); String url = "http://ribbon-provider/reqportinfo"; String res = restTemplate.postForObject(url, paramMap, String.class); System.out.println("responsepost json : " + JSONObject.toJSONString(res)); return res; }; ``` 这个是接收post请求的代码部分逻辑 ``` @RequestMapping(value = "/reqportinfo", method = RequestMethod.POST) public String getPortInfo(@RequestBody reqData req){ return helloService.getPortInfo(req) ; } ``` ``` public class reqData { private String hostName; private String ip; //省略get set } ``` 提示的错误 org.springframework.web.client.HttpClientErrorException$UnsupportedMediaType: 415 null at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:95) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:122) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:102) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:778) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:736) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:414) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at com.fangsir.ribbonnconsumer.Service.HelloService.getPortInfo(HelloService.java:26) ~[classes/:na] at com.fangsir.ribbonnconsumer.controller.HelloController.getPortInfo(HelloController.java:24) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.22.jar:9.0.22] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) ~[spring-webmvc-5.1.9.RELEASE.jar:5.1.9.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.22.jar:9.0.22]
Spring restTemplate 参数乱码
## Spring restTemplate 参数乱码 客户端代码: ``` public static RestTemplate creatTemplate(){ RestTemplate restTemplate=new RestTemplate(); FormHttpMessageConverter fc = new FormHttpMessageConverter(); StringHttpMessageConverter s = new StringHttpMessageConverter(StandardCharsets.UTF_8); List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>(); partConverters.add(s); partConverters.add(new ResourceHttpMessageConverter()); fc.setPartConverters(partConverters); MappingJackson2HttpMessageConverter jsonMessageConverter = new MappingJackson2HttpMessageConverter(); // Add supported media type List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(); supportedMediaTypes.add(new MediaType("text", "plain")); supportedMediaTypes.add(new MediaType("charset", "utf-8")); supportedMediaTypes.add(new MediaType("text", "html")); supportedMediaTypes.add(new MediaType("application", "json")); jsonMessageConverter.setSupportedMediaTypes(supportedMediaTypes); restTemplate.getMessageConverters().addAll(Arrays.asList(fc, jsonMessageConverter)); ClientHttpRequestInterceptor interceptor= new ClientHttpRequestInterceptor() { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpRequestWrapper wrapper = new HttpRequestWrapper(request); MediaType mt=MediaType.valueOf("application/json;charset=utf-8"); System.out.println(mt.getCharSet()); wrapper.getHeaders().setContentType(mt); wrapper.getHeaders().setAccept(Collections.singletonList(new MediaType("application", "json"))); wrapper.getHeaders().setAcceptCharset(Collections.singletonList(Charset.forName("utf-8"))); return execution.execute(wrapper, body); } }; restTemplate.setInterceptors(Collections.singletonList(interceptor)); return restTemplate; } public static void main(String[] args) { JSONObject js=new JSONObject(); JSONObject appSign=new JSONObject(); appSign.put("appkey", "xunyukeji"); appSign.put("timestamp", "12345678900"); appSign.put("sign", "F206BEB57018BDA4B2369CE998A5F1C5"); js.put("type", "S"); js.put("apiSign", appSign); JSONArray list=new JSONArray(); JSONObject item=new JSONObject(); item.put("message", "订单发货日期2017-01-10 16:13:31"); item.put("status", "S"); item.put("code", "shunfeng"); item.put("tradeNum", "5455454"); item.put("expressName", "顺丰快递"); list.add(item); js.put("list", list); RestTemplate restTemplate=creatTemplate(); JSONObject result=restTemplate.postForObject("http://192.168.0.126/webapp/wcs/stores/servlet/SBNUpdateOrderStatusCmd", js.toString(), JSONObject.class); System.out.println(result.toString()); } ``` 服务端参数处理代码: ``` public String getParams(HttpServletRequest request) throws IOException{ Enumeration<String> names = request.getHeaderNames(); while (names.hasMoreElements()) { String name = names.nextElement(); System.out.println("["+name + " : " + request.getHeader(name) + "]"); } request.setCharacterEncoding("utf-8"); // 读取请求内容 BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream())); String line = null; StringBuilder sb = new StringBuilder(); while((line = br.readLine())!=null){ sb.append(line); } // 将资料解码 String reqBody = new String(sb.toString().getBytes("ISO-8859-1"),"UTF-8"); return reqBody; } ``` 服务端接收的请求头和处理后的参数 ``` [17-2-9 12:53:32:875 CST] 000000ab SystemOut O [Accept : application/json] [17-2-9 12:53:32:876 CST] 000000ab SystemOut O [Content-Type : application/json;charset=utf-8] [17-2-9 12:53:32:876 CST] 000000ab SystemOut O [Accept-Charset : utf-8] [17-2-9 12:53:32:876 CST] 000000ab SystemOut O [User-Agent : Java/1.7.0_79] [17-2-9 12:53:32:876 CST] 000000ab SystemOut O [Host : 192.168.0.126] [17-2-9 12:53:32:877 CST] 000000ab SystemOut O [Connection : keep-alive] [17-2-9 12:53:32:877 CST] 000000ab SystemOut O [Content-Length : 235] [17-2-9 12:53:33:436 CST] 000000ab SystemOut O 2017-02-09 12:53:33,434 INFO [updateOrder] - 修改订单接收参数{"type":"S","apiSign":{"appkey":"xunyukeji","timestamp":"12345678900","sign":"F206BEB57018BDA4B2369CE998A5F1C5"},"list":[{"message":"??????2017-01-10 16:13:31","status":"S","code":"shunfeng","tradeNum":"5455454","expressName":"????"}]} [17-2-9 12:53:34:102 CST] 000000ab SystemOut O F206BEB57018BDA4B2369CE998A5F1C5 [17-2-9 12:53:34:103 CST] 000000ab SystemOut O 2017-02-09 12:53:34,102 INFO [updateOrder] - 密钥验证成功 ``` 可以看到中文部分都是乱码的,客户端和服务端的编码格式都是UTF-8,而且同样的代码服务端用main方法httpclient调用,参数处理后却是正常的
紧急求助! 我用springboot和springcloud做练习(restTemplate),两个一样的方法为什么会一个成功,一个报错?
![图片说明](https://img-ask.csdn.net/upload/201912/20/1576847749_372702.png) ++++++++++++++++++++++ ![图片说明](https://img-ask.csdn.net/upload/201912/20/1576847760_901827.png) +++++++++++++++++++++++ ![图片说明](https://img-ask.csdn.net/upload/201912/20/1576847790_527821.png) ++++++++++++++++++++++++ 2019-12-20 21:07:05.962 WARN 7776 --- [nio-8087-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class com.project.domian.User +++++++++++++++++++++++++++++++++++++++++ 在练习 怎么实现 java间的调用,一样的流程,为什么有一个会报错?
resttemplate的exchange(0方法中指定response的返回类型
两种方法Class<T>和ParameterizedTypeReference指定返回类型有什么区别,都在什么情况下适用?
springcloud zookeeper注册中心,在客服端用restTemplate 访问,第一次访问正常,第二次以后都是失败
springcloud zookeeper注册中心,在客服端用restTemplate 访问,第一次访问正常,第二次以后都是失败: 配置以及主要代码如下: 服务端: ``` 配置: server.port=8082 spring.application.name=service-zookeeper spring.cloud.zookeeper.discovery.register=true spring.cloud.zookeeper.discovery.enabled=true spring.cloud.zookeeper.discovery.root=/spring-cloud-service spring.cloud.zookeeper.connect-string=cdh01.com:2181,cdh02.com:2181,cdh03.com:2181 java: @RequestMapping(value ="/index") @ResponseBody public AjaxView index(@RequestBody String jsoninfo,HttpServletRequest request, HttpServletResponse response){ 。。。 } ``` 客户端: ``` server.port=8081 spring.application.name=getway-zookeeper spring.cloud.zookeeper.discovery.register=false spring.cloud.zookeeper.discovery.enabled=true spring.cloud.zookeeper.discovery.root=/spring-cloud-service spring.cloud.zookeeper.connect-string=cdh01.com:2181,cdh02.com:2181,cdh03.com:2181 spring.cloud.zookeeper.dependencies.service-zookeeper.required=true spring.cloud.zookeeper.dependencies.service-zookeeper.path=/service-zookeeper spring.cloud.zookeeper.dependencies.service-zookeeper.loadBalancerType=ROUND_ROBIN feign.hystrix.enabled=true ``` JAVA代码: ``` @RequestMapping(value ="/api/{service_name}/{interface_name}") @ResponseBody public String getApiSend( @RequestBody String jsoninfo, @PathVariable String service_name, @PathVariable String interface_name) { String get_url ="http://"+service_name+"/"+interface_name; return backService.getApiSend(jsoninfo,get_url); } ``` 都启动成功后,第一次访问正常,第二次访问就报错了,报错提示没有找到服务列表,但是服务列表确实打印出来了。如下: No up servers available from load balancer ,因为这个提示,没有服务,后续就报错空指针了。但是确实有服务查询到。而且DEBUG也打印出来了。 ``` 2019-05-19 14:37:55.547 WARN 164828 --- [nio-8081-exec-9] com.netflix.loadbalancer.RoundRobinRule : No up servers available from load balancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=service-zookeeper,current list of Servers=[zhucj:8082],Load balancer stats=Zone stats: {unknown=[Zone:unknown; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;] },Server stats: [[Server:zhucj:8082; Zone:UNKNOWN; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 08:00:00 CST 1970; First connection made: Thu Jan 01 08:00:00 CST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0] ]}ServerList:org.springframework.cloud.zookeeper.discovery.ZookeeperServerList@28667be9 [DEBUG][2019/05/1914:37:55549 ][org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136)] Resolving exception from handler [public java.lang.String com.example.demo.controller.PageController.getApiSend(java.lang.String,java.lang.String,java.lang.String)]: java.lang.NullPointerException [DEBUG][2019/05/1914:37:55552 ][org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136)] Resolving exception from handler [public java.lang.String com.example.demo.controller.PageController.getApiSend(java.lang.String,java.lang.String,java.lang.String)]: java.lang.NullPointerException [DEBUG][2019/05/1914:37:55555 ][org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136)] Resolving exception from handler [public java.lang.String com.example.demo.controller.PageController.getApiSend(java.lang.String,java.lang.String,java.lang.String)]: java.lang.NullPointerException [DEBUG][2019/05/1914:37:55558 ][org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:993)] Could not complete request java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:192) at com.google.common.cache.LocalCache.get(LocalCache.java:3931) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3936) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4806) at com.netflix.loadbalancer.LoadBalancerStats.getServerStats(LoadBalancerStats.java:175) at com.netflix.loadbalancer.LoadBalancerStats.getSingleServerStat(LoadBalancerStats.java:362) at com.netflix.loadbalancer.AvailabilityPredicate.apply(AvailabilityPredicate.java:73) at com.netflix.loadbalancer.AvailabilityPredicate.apply(AvailabilityPredicate.java:35) at com.netflix.loadbalancer.CompositePredicate.apply(CompositePredicate.java:52) at com.netflix.loadbalancer.CompositePredicate.apply(CompositePredicate.java:40) at com.netflix.loadbalancer.AvailabilityFilteringRule.choose(AvailabilityFilteringRule.java:86) at org.springframework.cloud.zookeeper.discovery.dependency.DependenciesBasedLoadBalancer.chooseServer(DependenciesBasedLoadBalancer.java:64) at org.springframework.cloud.zookeeper.discovery.dependency.DependencyRibbonAutoConfiguration$1.chooseServerByServiceIdOrDefault(DependencyRibbonAutoConfiguration.java:72) at org.springframework.cloud.zookeeper.discovery.dependency.DependencyRibbonAutoConfiguration$1.getServer(DependencyRibbonAutoConfiguration.java:65) at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.choose(RibbonLoadBalancerClient.java:76) at org.springframework.cloud.client.loadbalancer.InterceptorRetryPolicy.canRetry(InterceptorRetryPolicy.java:53) at org.springframework.retry.support.RetryTemplate.canRetry(RetryTemplate.java:375) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:278) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:180) at org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor.intercept(RetryLoadBalancerInterceptor.java:67) at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:92) at org.springframework.cloud.zookeeper.discovery.dependency.DependencyRestTemplateAutoConfiguration$1.intercept(DependencyRestTemplateAutoConfiguration.java:67) at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:92) at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:76) at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:723) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:680) at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:466) at com.example.demo.util.WebUtil.SendPost(WebUtil.java:86) at com.example.demo.service.BackService.getApiSend(BackService.java:18) at com.example.demo.controller.PageController.getApiSend(PageController.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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.doPost(FrameworkServlet.java:877) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 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.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 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.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 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.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 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.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:496) 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:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) [DEBUG][2019/05/1914:37:55574 ][org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:104)] Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@46dfd3ba 2019-05-19 14:37:55.585 ERROR 164828 --- [nio-8081-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause ``` 请帮忙看看,谢谢。
能解释下RestTemplate的作用,或者实际运用场景
能解释下RestTemplate的作用吗?是用来调用接口的同时对外开放接口?也就是中转接口服务,看了很多例子,都是可以调用api接口,同时,自己也可以在浏览器中进行访问传参,这个是为了和前端进行交互? ``` import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @RestController public class RestTemplateController { @Autowired private RestTemplate restTemplate; /*// Restful服务对应的url地址,解决硬编码问题 @Value("${user.userServicePath}") private String userServicePath;*/ @GetMapping("/template/{id}") public User findById(@PathVariable Long id) { // http://localhost:7900/user/是前面服务的对应的url User u=new User(); u = this.restTemplate.getForObject("http://localhost:7900/user/" + id, User.class); // u.setId(id); System.out.println(u); return u; } } ```
Java第一次创建对象速度会慢于之后的创建
我在创建一个对象时发现第一次new出的对象会耗时比较长,而后面的创建则会很快速,请问大神这是为什么? 代码如下: ``` public static void main(String[] args) throws InterruptedException { for(int i =0;i<5;i++){ long now = System.currentTimeMillis(); RestTemplate httpClient = new RestTemplate(); System.out.println(System.currentTimeMillis() - now); } } ``` 输出结果如下: ``` 1084 16 7 12 5 ``` 感谢大神回答!
springmvc restTemplate 415错误
小弟这2天在一个项目中需要调用别的项目接口。我使用的是spring中的restTemplate方法。 其中相关代码如下: ``` MultiValueMap<String, String> uriVariables = new LinkedMultiValueMap<String, String>(); uriVariables.add("message", JSONObject.fromObject(msg).toString()); uriVariables.add("userId", police.getUserId()); System.out.println("uriVariables=" + uriVariables); String mqttClient = restTemplate.postForObject( "http://192.168.1.102:8080/base/mqtt/insertMqttMessage.do", null, String.class, uriVariables); ``` 被调用的方法如下: ``` @RequestMapping(value = "/mqtt/insertMqttMessage.do", method = RequestMethod.POST, consumes="application/json;charset=utf-8") @ResponseBody public String insertMQTTMessage(HttpServletRequest request, HttpServletResponse response, @RequestBody MultiValueMap<String, String> uriVariables) throws Exception { Map<String, Object> result = new HashMap<String, Object>(); System.out.println("进入MQTT接口 uriVariables=" + uriVariables); return "success"; } ``` 在测试过程中,因为是在不同的项目中,所以我使用的是map传递参数。接受也是。 在当前情况下调用会报**415 Unsupported Media Type**错误。当我把参数之前的**@RequestBody**删掉时,不报错,但是打印出来的参数为空。当把接受参数改成一个具有相应字段的javabean时,也是报415错误。 纠结了一天没找到解决办法,求高手帮忙下,谢谢。
请问restTemplate怎么携带证书访问https双向认证的服务?请大佬解惑,最好有个例子,本人小白
请问restTemplate怎么携带证书访问https双向认证的服务?请大佬解惑,最好有个例子,本人小白
springcloud 使用 RestTemplate 获取不到数据是为什么?
看了网上的一个例程,写了一段程序, 原例程是跑起来是没问题的,但是我照着写就出错了 +++ ![图片说明](https://img-ask.csdn.net/upload/202001/03/1578044965_628122.png) ++++ ![图片说明](https://img-ask.csdn.net/upload/202001/03/1578044978_981700.png) +++ ![图片说明](https://img-ask.csdn.net/upload/202001/03/1578044996_279136.png) +++ ![图片说明](https://img-ask.csdn.net/upload/202001/03/1578045011_891157.png) +++ ![图片说明](https://img-ask.csdn.net/upload/202001/03/1578045248_484682.png) +++ 请问大神这两种写法有什么不同,为什么第一种会报错?
[求助!] RestTemplate 请求https接口报错的问题, 查无所获,
使用restTemplate在请求https接口的时候不通,使用方法: ``` import org.springframework.web.client.RestTemplate; ...... ResponseEntity<String> response = restTempLate.exchange(urlAppender.toString(), HttpMethod.POST, request, String.class); ``` 报错信息: ``` Caused by: javax.net.ssl.SSLException: SSL peer shut down incorrectly ``` 服务器:Windows server 2012 证书:请忽略https证书问题 curl https://ip:port 不通 防火墙中已经开放相关的端口和IP 服务器端支持的https协议有: ``` System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2,SSLv3"); ```
spring RestTemplate发送GET请求时内容采用GBK编码
碰到一个超级奇怪的问题,使用RestTemplate发送Get请求的时候,如果我的content内容为GBK转码后的内容,拼接到URL上面,然后正常发送后,收到的内容就是GBK转码后的内容,而不是中文 但是如果要是用HttpClient 或者 postMan直接发送收到的就是中文格式的内容,另外我发送之前把URl打印出来了,直接黏贴到地址栏后访问依然能收到中文
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
前端 | 2. 正则
转载请注明以下: 本文转自清自以敬的博客:https://blog.csdn.net/qq_45791147 文章目录1.转义2.正则表达式初步2.1.匹配字符2.1.1.组成元素2.1.2.基础正则的设计 1.转义 转义的作用: 当某个字符在表达式中具有特殊含义,例如字符串引号中出现了引号,为了可以使用这些字符本身,而不是使用其在表达式中的特殊含义,则需要通过转义符“\”来构建该字符转义...
有哪些让程序员受益终生的建议
从业五年多,辗转两个大厂,出过书,创过业,从技术小白成长为基层管理,联合几个业内大牛回答下这个问题,希望能帮到大家,记得帮我点赞哦。 敲黑板!!!读了这篇文章,你将知道如何才能进大厂,如何实现财务自由,如何在工作中游刃有余,这篇文章很长,但绝对是精品,记得帮我点赞哦!!!! 一腔肺腑之言,能看进去多少,就看你自己了!!! 目录: 在校生篇: 为什么要尽量进大厂? 如何选择语言及方...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
Docker 从入门到掉坑
Docker 介绍 简单的对docker进行介绍,可以把它理解为一个应用程序执行的容器。但是docker本身和虚拟机还是有较为明显的出入的。我大致归纳了一下,可以总结为以下几点: docker自身也有着很多的优点,关于它的优点,可以总结为以下几项: 安装docker 从 2017 年 3 月开始 docker 在原来的基础上分为两个分支版本: Docker CE 和 Doc...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
YouTube排名第一的励志英文演讲《Dream(梦想)》
Idon’t know what that dream is that you have, I don't care how disappointing it might have been as you've been working toward that dream,but that dream that you’re holding in your mind, that it’s po...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
相关热词 c# 二进制截断字符串 c#实现窗体设计器 c#检测是否为微信 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片
立即提问