请求主体将包含整个JSON内容。因此,当您要映射JSON时,仅使用一个RequestBody带注释的参数。您将必须执行以下操作:
public @ResponseBody Message subscribeUser(@RequestBody String str)ObjectMapper mapper = new ObjectMapper();JsonNode node = mapper.readTree(str);
然后使用映射器的convertValue方法从字符串中获取不同的对象。
JsonNode node = mapper.readTree(str);User theUser = mapper.convertValue(node.get("user"), User.class);对于其他对象类似



