Struts2 返回 json 的数组数据为 "空" 的解决方案

代码:
public List<User> list;//通过json返回的数据
struts配置文件:
1 <action name="test" class="cn.xzx.test.TestAction">
2      <result type="json">
3           <param name="includeProperties">list</param>       
4      </result>
5 </action>
结果:
{"list":[]}


解决方法:
1.  User一定要实现  Serializable 接口
2.  Action类中要求对应的getter方法
3.  配置文件修改为:
<result type="json">
     <param name="includeProperties"> list.* </param>       
</result>

猜你喜欢

转载自blog.csdn.net/xzx735/article/details/17917477