java ee - Avoiding POST requests resulting in "400 - Bad Request" status code in Spring MVC -


i have spring mvc application using annotation configuration. test controller looks that:

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

when user posts data controller , not enter valid long number ("somenumber"), spring mvc responds 400 - bad request http status code. application not chance react on error.

how problem handled?

i think best way handle add 'required' parameter 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


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -