gpt4 book ai didi

java - 覆盖 HTTP 响应状态文本

转载 作者:行者123 更新时间:2023-11-28 21:54:14 24 4
gpt4 key购买 nike

如何在 Tomcat 7 中覆盖 HttpStatu 的文本。

我正在使用 HttpServletResponse.sendError(401, "Invalid username or Password"),但是当我在客户端查看响应状态时,它转到了 401 Unauthorized.

有什么方法可以覆盖它吗?

最佳答案

Tomcat 不再支持 USE_CUSTOM_STATUS_MSG_IN_HEADER 属性。

更新日志来自 8.5.0 :

RFC 7230 states that clients should ignore reason phrases in HTTP/1.1response messages. Since the reason phrase is optional, Tomcat nolonger sends it. As a result the system propertyorg.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER is no longer usedand has been removed. (markt)

RFC 7230,超文本传输​​协议(protocol) (HTTP/1.1):消息语法和路由,2014 年 6 月。Section 3.1.2 :

The reason-phrase element exists for the sole purpose of providinga textual description associated with the numeric status code,mostly out of deference to earlier Internet application protocolsthat were more frequently used with interactive text clients. Aclient SHOULD ignore the reason-phrase content.

关于java - 覆盖 HTTP 响应状态文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20686465/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com