banner
指数爆炸

指数爆炸

我做了对饭 !
github
bilibili

No longer use URL path parameters

This is my backend interface:

@PostMapping("/test")
public String test(@RequestParam String account) {
    return "Hello, World! " + account;
}

This is the frontend request path:

http://localhost:8088/api/test/test?account=[111]

At first glance, there doesn't seem to be any problem, but in reality, URLs do not support special characters such as +, spaces, /, ?, %, #, &, =, etc. If you want to pass parameters by concatenating the request, you must escape these special characters.

Solution 1#

Change the request to:

http://localhost:8088/api/test/test?account=%5B111%5D

image

image
Reached the breakpoint

Solution 2#

The best solution is to avoid using URL path parameters and instead use form parameters in the body.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.