1

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.

Yuriy
  • 11
  • 4
  • is your media type 'application/x-www-form-urlencoded'? if you want to avoid convert to html entity, you can change media type to 'text/plain' or rename variable. – Huy Nguyen Dec 10 '21 at 14:44
  • It will not work to rename the variable, since the project is already large and a lot of logic is already tied to it. Well, I would like to solve the problem in the correct way, since in theory such errors should not occur. Tried `content-type: text/plain;charset=UTF-8` and it gave nothing :( – Yuriy Dec 13 '21 at 11:37

1 Answers1

0

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.

Aittou
  • 1
  • 1
  • Thanks, raising the version helped :) It is strange that without specifying the version of spring, gradle installed the version with a bug. – Yuriy Dec 11 '21 at 12:25
  • Cancel. The mistake has not gone anywhere. Upgrading the version didn't help :( implementation 'org.springframework.boot:spring-boot-starter-web:2.6.1' – Yuriy Dec 13 '21 at 10:30
  • what client do you use to send the post requests? – Aittou Dec 15 '21 at 08:11
  • [reqbin.com](https://reqbin.com/) or `axios` from code – Yuriy Dec 16 '21 at 14:34