我正在向 Controller 发布一个 JSON 对象,它显示 404 错误和消息“客户端发送的请求在语法上不正确。”
<html>
<form action= "action" method="post">
<input type ="text" name="user.name"/>
<input type ="text" name="user.pwd"/>
</form>
</html>
并在 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) {
..........
}
最佳答案
404 表示这是与资源命中有关的客户端错误。
如果添加问题时这不是拼写错误,请在操作及其值之间添加 =。
<html>
<form action="action" method="post">
<input type ="text" name="user.name"/>
<input type ="text" name="user.pwd"/>
</form>
</html>
关于java - 客户端发送的请求在语法上错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20097377/