简体   繁体   中英

Having a trouble with decoding a url query parameter by @RequestParam Spring @RestController

Url looks like: /getUserConnectionsList?login=**********&pagelimit=25&page=1&ot=asc&of=openDatetime&section=userActivity

@PostMapping(path = "getUserConnectionsList", params = {"login"})
public String getUserConnectionsList(@RequestParam String login,
                                     @RequestParam(required = false) String pagelimit,
                                     @RequestParam(required = false) String page,
                                     @RequestParam(required = false) String from,
                                     @RequestParam(required = false) String to,
                                     @RequestParam(required = false) String ot,
                                     @RequestParam(required = false) String of) {

    log.debug("test: {}, {}, {}, {}", login, page, ot, of);

And output looks like:

test: **********, 1, asc, openDatetime§ion=userActivity

It seems obvious that the following characters after openDatetime - "&sect", are interpreted as HTML ENTITY '§'. But I would like a know on how to solve this problem at the level of mapping, in order to avoid further situations when characters in a string are converted to a value I do not need.

To me it looks like your client side might make an encoding mistake, since the controller code with spring-boot-starter-web 2.6.1 is working fine if I call it with postman.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM