Under spingboot 2.x, I have a url http://localhost:8940/authorize/abc/getCode/{"client_id":"48e09e3-87b8395f7c5f","redirect_uri":"https://testvei.cn/vestomer/GjViQ?cardBag=1","state":"GWeiQ","scope":"phonginfo,openid","response_type":"code"}
And my controller method
@RequestMapping("/abc/getCode/**")
public void abcAuthorizeGetCode() {
Object path = request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
Object pathVariable = request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String pathParamJson = pathMatcher.extractPathWithinPattern((String) path, (String) pathVariable);
JSONObject params = JSON.parseObject(URLDecoder.decode(pathParamJson, "UTF-8"));
String redirectUri = params.getString("redirect_uri");
}
when sending request by that url ,I got a 400 error,says "Invalid character found in the request target". By removing "?" (the new Url http://localhost:8940/authorize/abc/getCode/{"client_id":"48e09e3-87b8395f7c5f","redirect_uri":"https://testvei.cn/vestomer/GjViQcardBag=1","state":"GWeiQ","scope":"phonginfo,openid","response_type":"code"}) it gots normal again, I've got confused .
And another question,why browers will auto encode illeagl characters in the path however character after the "?" will not ?
For example
http:// localhost:8940/d/{
will encode to
http:// localhost:8940/d/%7B
however
http:// localhost:8940/d?param={
will cause 400 error