我有一个 Java/Spring 应用程序,我正在使用 Spring 的 Rest 模板调用托管在 apache tomcat 容器上的网络服务,我想知道如何区分提供 404 页面的 tomcat 容器(例如,当应用程序未部署时)以及当我的网络服务返回 404 时(比如当我找不到帐户/资源时)。我是否被迫查看有效负载并找出返回的“Apache Tomcat”html 字符串?或者有更好的方法来区分这些吗? (即 tomcat 服务器上的一个设置公开了一个 header 值,可能会告诉我这是一个特定于应用程序容器的错误?)
下面列出了我们使用的版本。
- 带有 JDK 8 的 Tomcat 7.0.63
- Spring 4.3.3.RELEASE/Spring Boot 1.4.1.RELEASE
提前致谢
胡安
最佳答案
标题可能有助于区分两者。
tomcat 响应 http://localhost:8080/asd
内容长度:0
HTTP/1.1 404 Not Found
Server: Apache-Coyote/1.1
Content-Length: 0
Date: Sat, 28 Apr 2018 00:32:57 GMT
经理应用程序对 http://localhost:8080/manager/htmll 的响应
内容类型:text/html;charset=ISO-8859-1
内容长度:1534
HTTP/1.1 404 Not Found
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 1534
Date: Sat, 28 Apr 2018 00:39:10 GMT
关于spring - 我如何区分提供 404 的 Apache Tomcat 和我在 tomcat 上返回 404 的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50052943/