SPRINGMVC---400 error the request sent by the client is syntactically incorrect () __STRINGMVC

Source: Internet
Author: User
SPRINGMVC error message for the request sent by the client is syntactically incorrect ()
Be sure to decide when data binding the parameter names in the controller method and the names of the parameters in the JSP page are consistent or in accordance with the binding specifications, if not consistent, may return the following error: The request sent by the client is syntactically incorrect (). The literal understanding is that the client sent a request syntax error. The reality is that SPRINGMVC cannot implement data binding.
Give an example to illustrate:
<sf:form  method= "POST" commandname= "person" >
    	name:<sf:input path= "name"/><sf:errors path= " Name '/><br/>
    	pass:<sf:input path= ' pass '/><sf:errors path= ' pass '/><br age
    	: <sf:input path= "age"/><br/>
    	email:<sf:input path= "email"/><br/> The <input type=
    	" Submit "value=" Modify user "/>
    </sf:form>

	@RequestMapping (value= "/{name}/update", Method=requestmethod.post) public
	string Update (@PathVariable String name1, person person, Bindingresult BR)
	{
		System.out.println ("...");
		if (Br.haserrors ()) return
			"/update";
		Persons.put (Name1,person);
		return "Redirect:/listpersoninfo";
	}


The path in my form is name, and the controller Update method is name1.
And I made the mistake is: I submit the page in the form of the checksum, and in the Controller Update method before the Colonel to test the object without adding @validated, so will also report this error.
So controller should be modified as follows:

	@RequestMapping (value= "/{name}/update", Method=requestmethod.post) public
	string Update (@PathVariable String Name, @Validated person person, Bindingresult BR)
	{
		System.out.println ("...");
		if (Br.haserrors ()) return
			"/update";
		Persons.put (Name1,person);
		return "Redirect:/listpersoninfo";
	}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.