关于前台js编码后台java解码

可用函数

Js Java  说明
escape()

unescape()

将字符的unicode编码转化为16进制序列(转义序列,转义序列(escape sequences))

encodeURI() 

decodeURI()

将字符的unicode编码通过UTF-8
encodeURIComponent() 

decodeURIComponent()

将字符的unicode编码通过UTF-8

 

不编码字符

  不编码字符个数      
escape() 69个 *,_,-,.,0-9,a-z,A-Z   +,/,@
encodeURI()  82个 *,_,-,.,0-9,a-z,A-Z !, ',(,),~ #,$,&,+,,,/,:,;,=,?,@
encodeURIComponent()  71个 *,_,-,.,0-9,a-z,A-Z !, ',(,),~  

 

 springboot自动解码配置:

 server.tomcat.uri-encoding=UTF-8 # Character encoding to use to decode the URI.

 如果前台用的是encodeURI(),则不需要配置;如果是encodeURIComponent() ,则需要配置,否则将不会自动解码。

 

posted @ 2019-03-07 13:41  一年之旦  阅读(1018)  评论(0编辑  收藏  举报