问题描述
使用Postman调用Java api解密token时
token值为iRdLmVEYUUvoH1oDF2QhSVhJxXYMRCxzbtJsL01Iun2OLHY/FxNQOrAwF4Bj2cdp1vhsXt9BQtc+xmiyuCvyi2+Itl2qlvlCT6VwRM6UgQ5SBIiInGlLYCr+zDfOoQ74zh+xwW7M+43vIuLs6W0y7Rt86uZgmAR8gYwMLfvGnRg=
执行时报错如下:
原因分析
后台会自动转义特殊字符,如'+'被转义为空格。
解决方案
前端将token传给后端之前,将token先转义
iRdLmVEYUUvoH1oDF2QhSVhJxXYMRCxzbtJsL01Iun2OLHY%2FFxNQOrAwF4Bj2cdp1vhsXt9BQtc%2BxmiyuCvyi2%2BItl2qlvlCT6VwRM6UgQ5SBIiInGlLYCr%2BzDfOoQ74zh%2BxwW7M%2B43vIuLs6W0y7Rt86uZgmAR8gYwMLfvGnRg%3D
后端接收到被转义的字符串,会自动反转义,得到
iRdLmVEYUUvoH1oDF2QhSVhJxXYMRCxzbtJsL01Iun2OLHY/FxNQOrAwF4Bj2cdp1vhsXt9BQtc+xmiyuCvyi2+Itl2qlvlCT6VwRM6UgQ5SBIiInGlLYCr+zDfOoQ74zh+xwW7M+43vIuLs6W0y7Rt86uZgmAR8gYwMLfvGnRg=
postman需要转义,swagger则无需转义。