spring mvc 利用匿名内部类构建返回json对象

    @RequestMapping(value = "/order/findOrderByIdVague/{noId}.json", method = {RequestMethod.GET,RequestMethod.POST})
public @ResponseBody List findOrderByIdVague(@PathVariable String noId){
ApiModel model=null;
if (noId==null || noId.length()<6.){
model=new ApiModel("订单模糊查询只支持6个以上的字符",201);
return null;
}
List list= orderService.findOrderByIdVague(noId);
List<Object> resultList=new ArrayList<Object>(list.size()); for (final Object orderObject:list){
if (orderObject instanceof Object[]){
final Object[] orderStringObj= (Object[]) orderObject;
if (orderStringObj==null || orderStringObj.length!=5)
continue;;
Object object=new Object(){
private String value=(orderStringObj[0]==null?"":orderStringObj[0].toString());
private String masterNickname=(orderStringObj[1]==null?"":orderStringObj[1].toString());
private String masterMobile=(orderStringObj[2]==null?"":orderStringObj[2].toString());
private String memberNickname=(orderStringObj[3]==null?"":orderStringObj[3].toString());
private String memberMobile=(orderStringObj[4]==null?"":orderStringObj[4].toString()); public String getValue(){
return value;
}
public String getMasterNickname() {
return masterNickname;
}
public String getMasterMobile() {
return masterMobile;
}
public String getMemberNickname() {
return memberNickname;
}
public String getMemberMobile() {
return memberMobile;
}
};
resultList.add(object);
}
}
return resultList;
}

  

内部类的代码:
 Object object=new Object(){……}
上一篇:(Linux)CentOS7下安装JDK 1.8


下一篇:(转)解析PHP中ob_start()函数的用法