Spring MVC - HTTP status code 400 (Bad Request) for missing field which is defined as being not required -


i have spring mvc application controller method.

@requestmapping(value = "/add", method = requestmethod.post) public string addnumber(@requestparam(value="number", required=false) long number) {    ...    return "redirect:/showall/"; } 

in jsp have standard html form posting value named "number" controller method above. however, if leave out value (do not enter text field) , post data controller, before controller method called browser shows

http status 400 - required long parameter 'number' not present 

although controller method annotation defines "number"-parameter not required.

does have slight idea of going on?

thank you.

ps: exception being thrown follows:

org.springframework.web.bind.missingservletrequestparameterexception: required long parameter 'number' not present 

edit: spring 3.2.3.release bug ( see here). version 3.1.4.release not have problem anymore.

i came across same situation, , happens when parameter present in request empty value.

that is, if post body contains "number=" (with empty value), spring throws exception. however, if parameter not present @ in request, should work without errors.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -