java.net.MalformedURLException: no protocol

java.net.MalformedURLException: no protocol: https%3A%2F%2Fopen.t.qq.com%2Fapi%2Ft%2Fadd%3Fformat%3Djson%26content%3Dhelloword%21%26syncflag%3D0%26oauth_consumer_key%3D801444968%26access_token%3D52d9307ef4d64497a3c2445c3204cf0d%26openid%3DFC97442ED6834098CAEA31029E8263CE%26clientip%3D122.113.39.193%26oauth_version%3D2.a%26scope%3Dall
java.net.URL.<init>(URL.java:567)java.net.URL.<init>(URL.java:464)java.net.URL.<init>(URL.java:413)cn.damai.integration.web.action.UserAction.fetchHttpString(UserAction.java:112)cn.damai.integration.web.action.UserAction.pushWb(UserAction.java:189)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:597)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)cn.damai.integration.web.filter.AutoLoginFilter.doFilter(AutoLoginFilter.java:44)org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)

原因是,使用了get方式提交中文参数,需要转码,错误的做法是

//错误的做法是:
String encodedUrl = URLEncoder.encode(url, "utf-8");
//这样一来,就把url中的&?等字符进行了转码,如此就不能被正确的识别为url了
//争取的做法应该是只对请求参数进行转码
String url = "https://open.t.qq.com/api/t/add?" +
				"format=json" +
				"&content=" + URLEncoder.encode(this.content,"utf-8") +
				"&syncflag=0";



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值