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>購(gòu)物車</title>
</head>
<body>
<h1>購(gòu)物車</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="加入購(gòu)物車" /></td>
</tr>
</table>
</form>
</body>
</html>
如果你對(duì)Controller加了@RequestBody 玄括,那么你使用普通的post提交就會(huì)報(bào)415,那么去掉就好了
@RequestMapping("/cart/save") //以post請(qǐng)求來訪問
public SysResult save(@RequestBody Cart cart) {
return cartService.save(cart);
}