后端接受对象的两种写法

后端get请求

public ResponseEntity<CommodityRespM02> commoditySelectMap(@RequestParam Commodity commodity) throws Exception {

  ...........................

}

 

后端post请求

public ResponseEntity<CommodityRespM02> commoditySelectMap(@RequestBody Commodity commodity) throws Exception {

  ...........................

}

 

 

/**
* 对象转map
* @param bean
* @return
*/
public static <T> Map<String, Object> beanToMap(T bean) {
Map<String, Object> map = Maps.newHashMap();
if (bean != null) {
BeanMap beanMap = BeanMap.create(bean);
for (Object key : beanMap.keySet()) {
map.put(key + "", beanMap.get(key));
}
}
return map;
}

posted @ 2019-12-19 09:06  jassy  阅读(1157)  评论(0编辑  收藏  举报