springMvc直接自动转化对象为json的配置(不需要自己转成json) 博客分类: springmvc springMvc
springMvc直接自动转化对象为json的配置(不需要自己转成json)
/**
* 根据搜索条件,订单分类 查询订单数据(采购)
*/
@RequestMapping(value = "/myPurchase",produces="application/json")//直接转化成json
@ResponseBody
public Object findMyPurchase(Integer status,@RequestParam Map<String,String> searchData,Integer pageSize,Integer pageNum){
String searchKey=searchData.get("searchData[key]");
String searchValue=searchData.get("searchData[value]");
logger.debug("我的采购订单分类状态:"+status+"搜索条件:"+searchKey+"--"+searchValue+"分页数量:"+pageSize+"第几页:"+pageNum);
//得到登录用户
CusUserBean cusUserBean = CASUtil.getCusUserBean();
String CustomerKey="";
if(cusUserBean==null){
return "";
}else{
CustomerKey=cusUserBean.getCustomerKey();
}
//查询条件
Map<String,Object> map=new HashMap<>();
map.put("buyId", CustomerKey);
if(status!=null&&status!=0){
map.put("orderstatustype", status);
}
if(!searchKey.equals("")&&!searchValue.equals("")){
map.put(searchKey.trim(), searchValue);
}
//分页信息
SplitPageVo sp =null;
if(pageSize!=null&&pageNum!=null){
sp=new SplitPageVo();
sp.setPageSize(pageSize);
sp.setCurrentPage(pageNum-1);
}
Map<String, Object> maps=orderIronServ.getByOrdertypenameno(map,sp);
return maps;
}