Question: I have a Spring MVC application using annotation configuration. My test controller looks like that:

```
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String addNumber(@RequestParam("name") Long someNumber) {
    ...
    return "redirect:/showAll/";
}

```

When a user posts data to this controller and does not enter a valid Long number ("someNumber"), Spring MVC responds with a 400 - Bad Request HTTP status code. My application does not get a chance to react on that error.

How is this problem usually handled?

Answer: 
I think the best way to handle this is to add a 'required' parameter into RequestParam annotation.

```
@RequestParam(value="name", required=false)

```

<http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/RequestParam.html>
One solution would be to declare a default value for your parameter and then check that in application code:

```
@RequestParam(value="name", defaultValue="-1")

```

Or, if no default makes sense, just go with @diafour's answer and you'll get a `null` value.