微信小程序前后台使用get方式传参时报错如图。但在微信开发平台和苹果测试都没事,在安卓手机上就报这个错,猜想原因是get传递了汉字的原因。

尝试了下在后台输出从前台获取的参数,但是后台什么也没有获取到,直接报错。

最后用id替换了url里的中文;因为搜索功能不能替换中文的,改成了post请求。

参考:
【Java EE】get和post请求的编码过程
get请求中文参数乱码的解决之道

网上也有很多报这个错的原因是含有特殊字符:
有些版本的Tomcat严格按照 RFC 3986规范进行访问解析,
而 RFC 3986规范定义了Url中只允许包含英文字母(a-zA-Z)、数字(0-9)、-_.~4个特殊字符以及所有保留字符
(RFC3986中指定了以下字符为保留字符:! * ’ ( ) ; : @ & = + $ , / ? # [ ])。
传入的参数(例:"{")中有不在RFC3986中的保留字段中,会报这个错。例:http://localhost:8080/index.do?{id:123}
解决:
1. 去掉url中的特殊字符
2. 对参数进行url编码
3. 使用post提交
4. 更换更低版本的Tomcat
5. 在 conf/catalina.properties 中最后添加一行:
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
网上也有说添加下面一句,来允许禁止的字符:|{}
tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}
参考:https://blog.csdn.net/testcs_dn/article/details/71716829

关于对参数进行url编码:

例:对url中的||进行编码
(1) 前台对url编码:

encodeURI("http://localhost:8080/app/handleResponse?msg=name|id|")
> http://localhost:8080/app/handleResponse?msg=name%7Cid%7C

(2)只编码参数:

encodeURIComponent("msg=name|id|")
> msg%3Dname%7Cid%7C

java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986的更多相关文章

  1. Tomcat v7.0 java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    十二月 , :: 下午 org.apache.coyote.http11.AbstractHttp11Processor process 信息: Error parsing HTTP request ...

  2. 解决springboot项目请求出现非法字符问题 java.lang.IllegalArgumentException:Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    springboot版本: 2.1.5 最近使用springboot搭建了一个App后台服务的项目,开发接口的时候在本机使用postman工具做请求测试,请求返回一直很正常,但是在前端开发使用h5请求 ...

  3. IE浏览器连接WebSocket报错:java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    在项目开发中整合了WebSocket,本来没什么问题了,但是偶尔发现用IE浏览器打开web端不能推送消息,因为PC端与服务器建立连接失败了.网上查了很多资料, 又看了看源码,都不对症:又怀疑是Spri ...

  4. Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors...java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are

    先将异常信息贴出: 该问题是tomcat进行http request解析的时候报的错,网上的解决办法主要是修改Tomcat的server.xml,在<Connector port="8 ...

  5. java.lang.IllegalArgumentException: Invalid character found in the request target. The valid charact

    线上环境中部署的 Tomcat 项目,出现部分页面无法打开的情况,但本地环境是好的.经过排查发现,本地 Tomcat版本为 7.0.77,而线上版本为 7.0.88.报错的具体描述为java.lang ...

  6. 后台报错java.lang.IllegalArgumentException: Invalid character found in the request target.

    报错: Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. java.lang ...

  7. tomcat Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

      1.情景展示 tomcat 日志时不时会报出如下异常信息,到底是怎么回事? java.lang.IllegalArgumentException: Invalid character found ...

  8. 异常:Invalid character found in the request target. The valid characters are defined in RFC 3986

    一.背景 事情是这样的,前几天做一个基本的数据库“增删改查”的需求,前端传参的方式是“JSON字符串”,后端接收到此参数后,使用阿里巴巴fastjson进行解析,然后入库.需求很简单吧,但是偏偏遇到问 ...

  9. Tomcat报错Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    问题描述:后台报错 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.java ...

随机推荐

  1. Direct2D处理几何图形之间的碰撞检测(上)

    转载请注明出处:http://www.cnblogs.com/Ray1024 一.概述 Direct2D中支持以下几种类型的几何图形: a.简单几何图形(Simple Geometry):矩形.圆角矩 ...

  2. React——event

    1.绑定在React元素上的事件与绑定在DOM元素上的事件非常相似,但是也有一个不同的地方 React事件使用驼峰命名法命名 //在HTML中 <button onclick='handle() ...

  3. 转载Linux下开启MySQL日志

    转载https://blog.csdn.net/weixin_38187469/article/details/79273962 开启mysql日志   1.查看日志是否启用 mysql> sh ...

  4. nGrinder性能测试平台的安装部署

    1.从GitHub下载war包: https://github.com/naver/ngrinder/releases 2.把ngrinder-controller-3.4.2.war重命名为ngri ...

  5. idea配置SOLServer错误解决记录

    1.错误信息:2019-03-26 13:32:41.205 ERROR 7828 --- [nio-8081-exec-1] c.alibaba.druid.filter.stat.StatFilt ...

  6. linux镜像(持续更新)

    Linux系统历史衍生图:https://upload.wikimedia.org/wikipedia/commons/1/1b/Linux_Distribution_Timeline.svg ubu ...

  7. python类与对象的组合与继承

    1.把类的对象实例化放到一个新的类里面叫做类的组合,组合就是指几个横向关系的类放在一起,纵向关系的类放在一起是继承,根据实际应用场景确定.简单的说,组合用于“有一个”的场景中,继承用于“是一个”的场景 ...

  8. ETCD分布式存储部署

    一.ETCD 概述 ETCD 是一个分布式一致性k-v存储系统,可用于服务注册发现与共享配置.具有一下优点: 简单: 相比于晦涩难懂的paxos算法,etcd基于相对简单且易实现的raft算法实现一致 ...

  9. OTRS

    更新OTRS root@localhost密码: sudo -u otrs /opt/otrs/bin/otrs.Console.pl Admin::User::SetPassword root@lo ...

  10. gulp: Did you forget to signal async completion? 解决方案

    背景 学习gulp的前端自动化构建,按照示例代码,跑了一个简单的task,控制台打出如下提示: The following tasks did not complete: testGulp Did y ...