struts2注解 返回json时 params = {"includeProperties" 怎么设置多个对象 5
params={"includeProperties"}和excludeProperties怎么这设置多个啊??...
params = {"includeProperties"} 和excludeProperties 怎么这设置多个啊??
展开
2个回答
展开全部
params={"key1","value1","key2", "value2"}
如:@Result(name="success", type="json", params={"root","action","includeProperties", "result"}),
如:@Result(name="success", type="json", params={"root","action","includeProperties", "result"}),
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这里有个例子 不知道是不是你想要得效果;
StringBuffer sb = new StringBuffer();
sb.append("[");
for(int i=0;i<10;i++){
if(i>0){
sb.append(",");
}
sb.append("{");
sb.append("\"id\":\"" + i + "\",");
sb.append("\"name\":\"name" + i + "\",");
sb.append("\"age\":\"" + i*10 + "\"");
sb.append("}");
}
response.setCharacterEncoding("UTF-8");
response.getWriter().write(sb.toString());
打印出来的格式这样:
[{"id":"1","name":"name1","age":"10"},
{"id":"2","name":"name2","age":"20"},
{"id":"3","name":"name3","age":"30"},
..................
]
StringBuffer sb = new StringBuffer();
sb.append("[");
for(int i=0;i<10;i++){
if(i>0){
sb.append(",");
}
sb.append("{");
sb.append("\"id\":\"" + i + "\",");
sb.append("\"name\":\"name" + i + "\",");
sb.append("\"age\":\"" + i*10 + "\"");
sb.append("}");
}
response.setCharacterEncoding("UTF-8");
response.getWriter().write(sb.toString());
打印出来的格式这样:
[{"id":"1","name":"name1","age":"10"},
{"id":"2","name":"name2","age":"20"},
{"id":"3","name":"name3","age":"30"},
..................
]
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询