0

I have an application running using Spring Boot and Jetty. When I send a request to a wrong url (with content-type header set to application/json), it returns a 404 status code with some static text/html response as below:

<html>

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Error 404 Not Found</title>
</head>

<body>
    <h2>HTTP ERROR 404 Not Found</h2>
    <table>
        <tr>
            <th>URI:</th>
            <td>/my/bad/url</td>
        </tr>
        <tr>
            <th>STATUS:</th>
            <td>404</td>
        </tr>
        <tr>
            <th>MESSAGE:</th>
            <td>Not Found</td>
        </tr>
        <tr>
            <th>SERVLET:</th>
            <td>servlet</td>
        </tr>
    </table>

</body>

</html>

When I try the same bad request using a Tomcat webserver instead of Jetty, I get a response code 404 back with no body i.e. Content-length is 0.

I tried looking up the documentation for Jetty to find a probable configuration property that I might need to set to disable the return of this above static response but did not have much luck.

How can I disable the static response while using Spring boot and Jetty?

activelearner
  • 7,055
  • 20
  • 53
  • 94

0 Answers0