高手救救我吧:struts2的action里面,我获取了一个list对象,现在想把list转换成json传给ajax请求的结果

2025-02-01 08:05:46
推荐回答(1个)
回答1:

你的files是是数组
JSONArray.fromObject()这个是把list转换成json

加不加这个东西应是情况而定,你写的这个代码应该不用加

下面这种情况就要加
public String findall() throws Exception{
List newsTypeList=newsService.findalltype();

JSONArray json=JSONArray.fromObject(newsTypeList);
result=json.toString();

return SUCCESS;
}