/**
* 根据类型名称查询字典的方法:findByTypeCode
* @throws IOException
*/
public String findByTypeCode() throws IOException{
//调用业务层查询
List<BaseDict> list = baseDictService.findByTypeCode(baseDict.getDict_type_code());
// 将list转成JSON.---- jsonlib fastjson
/**
* JSONConfig:转JSON的配置对象
* JSONArray :将数组和list集合转成JSON
* JSONObject:将对象和Map集合转成JSON
*/
//用jsonConfig配置对象把不需要的数据去掉,最后调用fromobject转换JSON即可。
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setExcludes(new String[]{"dict_sort","dict_enable","dict_memo"});
JSONArray jsonArray = JSONArray.fromObject(list,jsonConfig);
System.out.println(jsonArray.toString());
// 将JSON打印到页面:
ServletActionContext.getResponse().setContentType("text/html;charset=UTF-8");
ServletActionContext.getResponse().getWriter().println(jsonArray.toString());
return NONE;
}