# 400 Bad Request in Spring Boot

> Map a Spring MVC 400 to its exception: unreadable JSON body, failed @Valid, missing parameter, type mismatch. Includes ProblemDetail error handling code.

Canonical: https://scaplet.com/errors/http/400/spring-boot

Guide Error · HTTP status codes

Map a Spring MVC 400 to its exception: unreadable JSON body, failed @Valid, missing parameter, type mismatch. Includes ProblemDetail error handling code.

3 min

read

3

sources

Oct 31, 2026

updated

Scaplet Editorial Team

author

400 4xx · Client error

The short answer

Spring MVC turns a fixed list of exceptions into 400: HttpMessageNotReadableException for an unreadable body, MethodArgumentNotValidException for failed bean validation, MissingServletRequestParameterException, TypeMismatchException and a few others. Find the exception in your logs, then fix the request or handle that exception to return a useful body.

1. [The seven exceptions behind a Spring MVC 400](#the-seven-exceptions-behind-a-spring-mvc-400)
2. [Reproduce and check it in 2 minutes](#reproduce-and-check-it-in-2-minutes)
3. [Handle it once, for every controller](#handle-it-once-for-every-controller)
4. [What it means for SEO and crawlers](#what-it-means-for-seo-and-crawlers)

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F400%2Fspring-boot%20(%22400%20Bad%20Request%20in%20Spring%20Boot%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F400%2Fspring-boot%20(%22400%20Bad%20Request%20in%20Spring%20Boot%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F400%2Fspring-boot%20(%22400%20Bad%20Request%20in%20Spring%20Boot%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F400%2Fspring-boot%20(%22400%20Bad%20Request%20in%20Spring%20Boot%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

_01_Exceptions mapped to 400, per the Javadoc

## The seven exceptions behind a Spring MVC 400

Spring's `DefaultHandlerExceptionResolver` converts framework exceptions into status codes before your controller returns anything. Its Javadoc lists seven that become 400. The rest of this page assumes you know which one you have, so start by finding its class name in the application log.

Exception

### `HttpMessageNotReadableException`

Typical trigger

Request body missing, or not parseable as the type the handler expects

Exception

### `MethodArgumentNotValidException`

Typical trigger

A `@Valid` or `@Validated` `@RequestBody` argument failed validation

Exception

### `HandlerMethodValidationException`

Typical trigger

Validation failed on the parameters of a controller method

Exception

### `MissingServletRequestParameterException`

Typical trigger

A required `@RequestParam` is absent

Exception

### `MissingServletRequestPartException`

Typical trigger

A required multipart part is absent

Exception

### `ServletRequestBindingException`

Typical trigger

Request binding failure

Exception

### `TypeMismatchException`

Typical trigger

A value cannot convert to the parameter type, such as text for an integer

Three nearby exceptions are not 400. The Javadoc maps `MissingPathVariableException` to 500, `MethodValidationException` (service-layer validation) to 500, and `HttpMessageNotWritableException` to 500. A 500 that looks like a validation problem can mean the constraint sits on a service bean, not a controller method.

_02_Check it

## Reproduce and check it in 2 minutes

Then fire three requests at your own app to see three different causes. These need a running application (replace the port and routes with your own):

Your own app: unreadable body, then a bad type, then a missing parameter

```
# 1. Malformed JSON body -> HttpMessageNotReadableException curl -s -i -X POST -H 'Content-Type: application/json' -d '{"name": ' http://localhost:8080/api/items # 2. Text where the handler expects an int -> TypeMismatchException curl -s -i http://localhost:8080/api/items?page=abc # 3. Required parameter left out -> MissingServletRequestParameterException curl -s -i http://localhost:8080/api/search # Expect: HTTP/1.1 400 on each; the log line names the exception class
```

If a request returns 400 and the log shows none of the classes in the table, the 400 is coming from somewhere else, such as the embedded server rejecting a malformed request line, or your own code throwing a `ResponseStatusException`.

Public endpoint: a known 400

```
curl -s -o /dev/null -w "%{http_code}\n" https://httpbin.org/status/400 # Expect: 400
```

_03_Your call

## Handle it once, for every controller

Every Spring MVC exception implements `ErrorResponse`, which carries the status, headers and an RFC 9457 body. The reference documentation's one-step fix is to extend `ResponseEntityExceptionHandler` in a `@ControllerAdvice`:

If this fits

### Fix the client when

- The body is not valid JSON or has the wrong field types
- A required parameter or header is missing
- Your API contract says the request is wrong

Or

### Change the server when

- A well-formed request is rejected by a constraint that is too strict
- Callers cannot tell why they got 400 because the body is empty
- You return 400 from your own code where 404 or 409 fits

Enable RFC 9457 problem responses for all built-in exceptions

```
@ControllerAdvice public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { }
```

The status of the response is the `status` property of the `ProblemDetail`. To add your own exception with extra fields, return a `ProblemDetail` from an `@ExceptionHandler`. This adapts the docs' example to a 400:

A custom exception mapped to 400 with a non-standard field

```
@ExceptionHandler(InvalidFilterException.class) public ProblemDetail handleInvalidFilter(InvalidFilterException ex) { ProblemDetail pd = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ex.getMessage()); pd.setProperty("field", ex.getField()); // non-standard field return pd; }
```

**Customize one message, not the whole handler**The reference docs say you can override a protected method on `ResponseEntityExceptionHandler` or add a `MessageSource` entry keyed like `problemDetail.org.springframework.web.bind.MissingServletRequestParameterException`.

_04_Explained

## What it means for SEO and crawlers

Google's documentation says it does not use content from, and does not index, URLs that return a 4xx status, and that 4xx codes other than 429 do not affect crawl rate. An API behind a Spring Boot app is rarely crawled, but a server-rendered page returning 400 for an optional query parameter is. Make optional parameters optional with `required = false` or a default, so a crawler that drops a parameter still gets a page. For the auth cousins of this error, see [401 in Spring Boot](/errors/http/401/spring-boot) and [403 in Spring Boot](/errors/http/403/spring-boot).

Sources · 3

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- spring.io
- google.com

1. 01 [Spring Framework API: DefaultHandlerExceptionResolver](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.html) docs.spring.io · checked 2026-11-01
2. 02 [Spring Framework reference: Error responses (RFC 9457)](https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-ann-rest-exceptions.html) docs.spring.io · checked 2026-11-01
3. 03 [How HTTP status codes affect Google's crawlers](https://developers.google.com/search/docs/crawling-indexing/http-network-errors) developers.google.com · checked 2026-11-01

Questions

## Asked a lot.

2 questions people ask next, answered from the sources on this page.

_01_ Why does a failed @Valid return 400 and not 422?

Spring MVC maps MethodArgumentNotValidException to 400 in DefaultHandlerExceptionResolver. You can return a different status from your own handler if your API contract prefers it.

_02_ How do I see which exception caused the 400?

Look for the exception class name in the application log. Spring resolves it before the controller runs, and the class name tells you which row of the mapping applied.

## Keep learning

[All errors](/errors)

[Learn HTTP 400 Bad Request HTTP status codes](/errors/http/400) [Related 4xx errors Status codes and links](/seo-issues/4xx-errors) [Read next 401 Unauthorized in Spring Boot HTTP status codes](/errors/http/401/spring-boot) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 400 errors
[400 Bad Request in Django](/errors/http/400/django) [400 Bad Request in Flask](/errors/http/400/flask) [400 Bad Request in nginx](/errors/http/400/nginx) [CloudFront 400: Bad Request](/errors/cdn/cloudfront-400) [HTTP 400 Bad Request](/errors/http/400)

Nearby in errors
[HTTP 401 Unauthorized](/errors/http/401) [401 Unauthorized in IIS](/errors/http/401/iis)

More in HTTP 400 Bad Request
[400 Bad Request in Apache httpd](/errors/http/400/apache) [400 Bad Request in Chrome](/errors/http/400/chrome) [400 Bad Request in Django](/errors/http/400/django) [400 Bad Request in Flask](/errors/http/400/flask) [400 Bad Request in nginx](/errors/http/400/nginx) [400 Bad Request in Spring Boot](/errors/http/400/spring-boot)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
