如何使用restclient来发送post请求参数
1个回答
2016-11-27 · 知道合伙人软件行家
关注
展开全部
Java代码
@RequestMapping(value = "/test", method = { RequestMethod.GET,
RequestMethod.POST })
public void test(HttpServletResponse response, @RequestBody String message) {
这里的:@RequestBody String message
LOGGER.debug(String.format("receive message %s", message));
Map<String, String> map = Maps.newHashMap();
try {
map.put("result", message);
Tools.printToJson(JSON.toJSONString(map), response);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
如果传递的是一个对象给springmvc,如(代码不全):
Java代码
public class EntitySubscribe {
private Long entityId;
private String entityCode;
private String entityName;
private String teamCode;
private SubscribeUsesEnum subscribeUsesEnum;
private Date gmtCreate;
private Date gmtModify;
private Long flowId;
private OnOffEnum state;
private String reason;
private List<Integer> uses;
}
@RequestMapping(value = "/test", method = { RequestMethod.GET,
RequestMethod.POST })
public void test(HttpServletResponse response, @RequestBody String message) {
这里的:@RequestBody String message
LOGGER.debug(String.format("receive message %s", message));
Map<String, String> map = Maps.newHashMap();
try {
map.put("result", message);
Tools.printToJson(JSON.toJSONString(map), response);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
如果传递的是一个对象给springmvc,如(代码不全):
Java代码
public class EntitySubscribe {
private Long entityId;
private String entityCode;
private String entityName;
private String teamCode;
private SubscribeUsesEnum subscribeUsesEnum;
private Date gmtCreate;
private Date gmtModify;
private Long flowId;
private OnOffEnum state;
private String reason;
private List<Integer> uses;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询