Reputation: 537
I am posting a JSON object to the controller, it is showing a 404 error and the message "The request sent by the client was syntactically incorrect."
<html>
<form action= "action" method="post">
<input type ="text" name="user.name"/>
<input type ="text" name="user.pwd"/>
</form>
</html>
and catching in controller
@RequestMapping(value = "/action", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public @ResponseBody
public void createuser(@RequestBody UserDTO request,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
..........
}
Upvotes: 0
Views: 114
Reputation: 537
There are two reasons for my problem
1.we need to check the passing attributes with server side DTO. if any mispellling it psoting this error
2.all the attribures we are passing to server should be present in DTO . if any extra attributes occurs which posses the error then you need to delete attibute from json Object like delete jsonObject.extra object
Upvotes: 0
Reputation: 6855
404 says its a client side error with respect to the resource hit.
If that isn't a typo while adding the question, then add = between the action and its value.
<html>
<form action="action" method="post">
<input type ="text" name="user.name"/>
<input type ="text" name="user.pwd"/>
</form>
</html>
Upvotes: 1