java - 表单应用程序编码值在弹簧休息时不起作用
问题描述
我有以下发布请求,其中以下是控制器代码
@RestController
@RequestMapping(/flow", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@Override
@ResponseStatus(HttpStatus.OK)
@PostMapping("{abcCode}/token")
public TokenResponse createToken(@PathVariable("abcCode") String abcCode,
@RequestParam("grant_type") String grantType,
@RequestParam String code,
@RequestParam("redirect_uri") String redirectUri,
@RequestParam String clientId) {
LOG.info(
"Received call for createIdToken for abcCode: {} , clientId: {} , grantType: {} ,code: {} , redirectUri: {}",
abcCode, clientId, grantType, code, redirectUri);
}
现在的问题是,当我通过邮递员通过选择正文类型作为应用程序表单编码来测试相同的上述控制器时,它工作正常但是当我在邮递员中选择正文类型为无并且只是将上述请求参数作为查询一传递那么它也可以工作,理想情况下它不应该请告知我如何克服同样的问题
它不适用于上述网址
解决方案
来自弹簧来源:
public static final String APPLICATION_FORM_URLENCODED_VALUE = "application/x-www-form-urlencoded";
根据 docs,当使用 url-form-encoded 数据作为查询参数传递时。尝试更改表单 mime 类型。
推荐阅读
- flutter - 如何仅在 FutureBuilder 获取 snapshot.data 后加载列表?
- javascript - webRTC nodejs在vercel中部署后不起作用
- php - PHP preg_match_all - 以不同的顺序从模式中提取内容
- javascript - JavaScript:如何检查 OpenWeather API 城市列表中是否存在城市名称:错误检查
- c++ - shared_ptr 被提前删除
- installshield - 如何修复“installShield 2020 中的构建错误”
- javascript - React Material UI Table - 同时切换所有切换
- php - PHP - file_get_contents() 在本地主机上完美运行,但在实时服务器上运行
- flutter - 谁能告诉这个对话框有什么问题?
- python - pyautogui 模块的 typewrite 命令未提供所需的输出