I know that there is a lot of similar questions, but none of them helps me.
on server i hav method:
<div class="layout-container">
<nav class="navbar navbar-default">
<div id="navbar">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#" data-toggle="modal" data-target="#loginModal">Join us</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">Rankings</a></li>
<li><a href="#">Vote</a></li>
<li><a href="#">Community</a></li>
</ul>
</div><!--/.container-fluid -->
</nav>
<div class="container">
<div class="layout-sidebar">
<div class="side-control">
<header><h2>Sidebar</h2></header>
<div class="side-content">
Content here
</div><!--/.side-content -->
</div><!--/.side-control -->
</div><!--/.layout-sidebar -->
<div class="col-md-9">
Content here
</div><!--/.col-md-9 -->
</div><!--/.container -->
</div><!--/.layout-container -->
and on the clien side i send a request:
@RequestMapping(value = "/event", method = RequestMethod.POST , produces = MediaType.APPLICATION_JSON_VALUE)
public void bookOpened(
@RequestParam(value="id", required = true) int id,
@RequestParam(value="type", required = true) String type,
HttpServletRequest request, HttpServletResponse response, HttpSession httpSession) {
}
requests end with error 400(bad request) and i dont know why
答案 0 :(得分:1)
You need to use @RequestBody annotation in method parameters. For more info see, for example, here: Parsing json into java objects in spring-mvc