The rear end accepts two objects writing

Backend get request

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

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

}

 

Back-end post request

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;
}

Guess you like

Origin www.cnblogs.com/jassy/p/12065836.html