SpringMVC 返回json

1.导入jackson的jar包

2.在方法体上加上@ResponseBody

/**
     * 得到ProType的typeId,typeName列表
     * 返回json
     * */
    @RequestMapping("/getAllProType")
    @ResponseBody
    public List<Object> getAllProType() {
        return adminSer.getColum("ProType", new String[] {"typeId","typeName"});
    }

3.浏览器访问就可以得到json数据了

原文地址:https://www.cnblogs.com/wwzyy/p/5605923.html