前后端交互json字符串

 


//
将需要的参数转成json字符串,然后用utf-8编码 var obj = encodeURIComponent(JSON.stringify(this.categories),"utf-8")
//后台将前台的json字符串按照utf-8的格式解码,然后进行转换
@RequestMapping(value = "/updateMaterialDemoInfo.do", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> updateMaterialDemoInfo(String obj){
        
        List<MaterialDemoInfoDTO> list = new ArrayList<MaterialDemoInfoDTO>();
        try {
            String param = URLDecoder.decode(obj,"utf-8");
            list = (List<MaterialDemoInfoDTO>)JSonUtil.json2Obj(param, MaterialDemoInfoDTO.class);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        return materialDemoService.updateMaterialDemoInfo(list);
    }

 

 

public class MaterialDemoInfoDTO {
    
    // 主键ID
    private String id;
    

    //路径
    private String [] path;
    
    
    //物资器材模板id
    private String demoId;
    
    //数量
    private String num;
    
    //序号
    private String sort;
    
    //类型备注
    private String remark;

 

posted @ 2018-11-21 17:54  爱吃西红柿  阅读(1121)  评论(0编辑  收藏  举报