【发布时间】:2017-09-18 15:29:30
【问题描述】:
我有一个使用自定义状态码的小演示。
有趣的是,如果状态低于 200,请求将始终挂在那里,例如 105、199 等。但适用于任何大于 200 的状态,例如 209、789 等。
Http状态码注册,参考https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
Spring boot:1.5.4.RELEASE 与嵌入式 tomcat
Java:8
控制器:
@RestController
public class DemoController {
@GetMapping("/hello")
public ResponseEntity get() {
return ResponseEntity.status(105).build();
}
}
谁能给我一个明确的解释?
我在这里创建一个要点:https://gist.github.com/pengisgood/dbea1fcdc45c2bb5809871c7f020b800
更新:
我还在这里创建了一个小演示来重现它: https://github.com/pengisgood/springboot-customize-status-code
更新:
在我运行curl -v localhost:8080/hello 之后,我可以看到状态,但是响应没有完成。参考下图:
【问题讨论】:
-
如果您尝试状态 103,它是否有效?
-
@VHS 不,它不起作用。
-
试试
ResponseEntity.status(HttpStatus.CHECKPOINT).build();怎么样? -
还是没有运气。
-
恐怕我无法提供进一步的帮助。希望您能尽快找到解决方案。
标签: java spring-boot kotlin http-status-codes