【问题标题】:RestController PutMapping malformed url when using "[]"使用“[]”时,RestController PutMapping 的 url 格式错误
【发布时间】:2020-10-08 12:09:45
【问题描述】:

我有一个 Spring App 女巫使用这样的控制器:

@PutMapping("/block/{blockid}/service/{serviceid}")
    public ResponseEntity<String> config(@PathVariable blockid, @PathVariable serviceid, @RequestBody String body) {
{

如果我将此请求发送到此 url,我使用 Postman 测试请求: 网址:localhost:7000/block/myBlockTest/service/externalServiceTest[0]

响应此错误:

说明服务器不能或不会处理 由于某些被认为是客户端错误的请求 (例如,格式错误的请求语法、无效的请求消息帧,或 欺骗性请求路由)。

我知道问题出在 url 中的 "[0]"

有什么方法可以在 URL 中发送?

谢谢。

【问题讨论】:

    标签: spring-boot rest http


    【解决方案1】:

    好的,我只需要将请求修改为 localhost:7000/block/myBlockTest/service/externalServiceTest%5B0%5D

    特殊参数。 https://cachefly.zendesk.com/hc/en-us/articles/215068626-How-to-format-URLs-that-have-special-characters-in-the-filename-

    【讨论】:

      猜你喜欢
      • 2014-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-27
      • 2017-01-01
      相关资源
      最近更新 更多