Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Nov 13 14:41:09 CST 2018
There was an unexpected error (type=Unsupported Media Type, status=415).
Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>购物车</title>
</head>
<body>
<h1>购物车</h1>
<form action="/cart/save" method="post">
<table border="1">
<tr>
<td>userId</td>
<td><input type="text" name="userId" /></td>
</tr>
<tr>
<td>itemId</td>
<td><input type="text" name="itemId" /></td>
</tr>
<tr>
<td>itemTitle</td>
<td><input type="text" name="itemTitle" /></td>
</tr>
<tr>
<td>itemImage</td>
<td><input type="text" name="itemImage" /></td>
</tr>
<tr>
<td>itemPrice</td>
<td><input type="text" name="itemPrice" /></td>
</tr>
<tr>
<td>num</td>
<td><input type="text" name="num" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="加入购物车" /></td>
</tr>
</table>
</form>
</body>
</html>
如果你对Controller加了@RequestBody ,那么你使用普通的post提交就会报415,那么去掉就好了
@RequestMapping("/cart/save") //以post请求来访问
public SysResult save(@RequestBody Cart cart) {
return cartService.save(cart);
}