接口被调用 返回jsonArray 处理jsonArray数据

 
 @RequestMapping(value = "/querySource.htm",method = RequestMethod.POST)
public String init(HttpServletRequest request ) throws IOException {

Map<String,String> map = new HashMap<String,String>();
        Enumeration<?> fields = request.getParameterNames();

        while(fields.hasMoreElements())
        {
            String field = (String) fields.nextElement();
            String[] values = request.getParameterValues(field);
            if (values.length > 1)
                map.put(field,values.toString());
            else
                map.put(field,values[0]);
        }
        logger.info("***接口返回jsonArray:"+map.get("jsonArray"));




if(map.get("jsonArray")!=null && map.get("jsonArray").length()>0){
 String arrayStr = map.get("jsonArray");

            List<PostAccountVO> postAccountVOList = new ArrayList<PostAccountVO>();

            List<Map<String,String>> listObjectSec = JSONArray.parSEObject(arrayStr,List.class);
            Map<String,String> mapList = new HashMap<String,String>();
            for(int i=0;i<listObjectSec.size();i++){
                mapList = listObjectSec.get(i);
                JSONObject jsonObject = JSONObject.fromObject(mapList);
                PostAccountVO postAccountVO=(PostAccountVO)JSONObject.toBean(jsonObject,PostAccountVO.class);
                postAccountVOList.add(postAccountVO);
            }
            logger.info("接口jsonArray数据转对象:"+postAccountVOList);


}


}

对方是以http的方式访问我的就接口

相关文章

AJAX是一种基于JavaScript和XML的技术,能够使网页实现异步交...
在网页开发中,我们常常需要通过Ajax从后端获取数据并在页面...
在前端开发中,经常需要循环JSON对象数组进行数据操作。使用...
AJAX(Asynchronous JavaScript and XML)是一种用于创建 We...
AJAX技术被广泛应用于现代Web开发,它可以在无需重新加载页面...
Ajax是一种通过JavaScript和HTTP请求交互的技术,可以实现无...