springboot 内置默认启动tomcat容器遇到The valid characters are defined in RFC 7230 and RFC 3986”

URL:

http://127.0.0.1:8081/test?urlcount=2&countcname1=参数名1&countname1=参数1&countcname2=参数名2&countname2=参数2

后台模拟post请求时路径报错:

The valid characters are defined in RFC 7230 and RFC 3986”

原因是因为url中含有中文.

直接进行中文转义:

URLEncoder.encode(参数名1,"utf-8")

URLEncoder.encode(参数1,"utf-8")

转义后为:

http://127.0.0.1:8081/test?urlcount=2&countcname1=%E5%90%8D%E7%A7%B01&countname1=%E5%8F%82%E6%95%B01&countcname2=%E5%90%8D%E7%A7%B02&countname2=%E5%8F%82%E6%95%B02

模拟正常.

猜你喜欢

转载自www.cnblogs.com/xy888/p/9269743.html