ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

@RequestMapping处理请求异常

2026/9/10 17:31:18 拓冰建站 浏览量
@RequestMapping处理请求异常

使用@RequestMapping不指定请求方式,多种请求方式都支持。
在这里插入图片描述
在这里插入图片描述

Get格式FORM_URLENCODED

Content-Type=application/x-www-form-urlencoded
URL形式传参,请求体里面的内容是:username=john@example.com&password=secretpassword&grant_type=password,
key=value&k1=v1的格式。
在这里插入图片描述
可以使用@RequestParam(“key1”)方式接收参数。

Post格式FORM_URLENCODED

Content-Type=application/x-www-form-urlencoded
在这里插入图片描述

使用hutool工具类发起Post请求,如果请求体的内容不能解析成:JSON application/json、XML application/xml这两种格式,请求头的请求内容会自动解析成FORM_URLENCODED application/x-www-form-urlencoded格式。

HttpResponse response = HttpRequest.post("url").body("null").header("userAuthCode", "authCode").execute();

hutool工具类发起Http请求

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
使用hutool发起http请求,请求体的内容无法被识别成xml或json,又没有指定请求头的Content-type方式,就会使用这个默认方式。
在这里插入图片描述