- 浏览: 70655 次
-
文章分类
最新评论
struts2处理json
5.1. root参数:从归回结果中根据ognl表达式掏出你需要输出的结果<wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 如:</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> action类</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class BaseAction extends ActionSupport implements</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> {</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> private Person person = null;</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> }</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class BaseAction extends ActionSupport implements {private Person person = null;...}</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> bean类</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 1</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class Person</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> {</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> private String name;</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> private int age;</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> }</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class Person {private String name;private int age;...}</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 我们只要输出person对象的name属性值,配置如次</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 1</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><img title="struts2处理json" alt="struts2处理json" src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" style="text-align:left; padding-bottom:0px; line-height:21px; border-right-width:0px; list-style-type:none; margin:0px; padding-left:0px; padding-right:0px; font-family:tahoma,arial,宋体,sans-serif; border-top-width:0px; border-bottom-width:0px; color:rgb(51,51,51); font-size:14px; border-left-width:0px; padding-top:0px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="root">person.name</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="root">person.name</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.2. excludeNullProperties 参数:表示是不是去掉空值, 默认值是false,如果设置为true会自动将为空的值过滤,只输出不为空的值。</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="excludeNullProperties">true</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="excludeNullProperties">true</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.3. ignoreHierarchy 参数:表示是不是纰漏等级,也就是继承关系,好比:TestAction继承于BaseAction,那么TestAction中归回的json字符串默 认是不会包含父类BaseAction的属性值,ignoreHierarchy值默认为true,设置为false后会将父类以及子类的属性一起归回。</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="ignoreHierarchy">false</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="ignoreHierarchy">false</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.4. includeProperties 参数:输出结果中需要包含的属性值,这搭正则表达式以及属性名匹配,可以用“,”分割填充多个正则表达式。</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 如:输出person的所有属性</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="includeProperties">person.*, person\.name</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="includeProperties">person.*, person\.name</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.5. excludeProperties 参数:输出结果需要剔掉的属性值,也支持正则表达式匹配属性名,可以用“,”分割填充多个正则表达式,大致相同4.4.</span></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
5.1. root参数:从归回结果中根据ognl表达式掏出你需要输出的结果<wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 如:</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> action类</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class BaseAction extends ActionSupport implements</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> {</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> private Person person = null;</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> }</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class BaseAction extends ActionSupport implements {private Person person = null;...}</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> bean类</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 1</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class Person</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> {</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> private String name;</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> private int age;</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> }</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> public class Person {private String name;private int age;...}</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 我们只要输出person对象的name属性值,配置如次</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 1</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><img title="struts2处理json" alt="struts2处理json" src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" style="text-align:left; padding-bottom:0px; line-height:21px; border-right-width:0px; list-style-type:none; margin:0px; padding-left:0px; padding-right:0px; font-family:tahoma,arial,宋体,sans-serif; border-top-width:0px; border-bottom-width:0px; color:rgb(51,51,51); font-size:14px; border-left-width:0px; padding-top:0px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="root">person.name</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="root">person.name</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.2. excludeNullProperties 参数:表示是不是去掉空值, 默认值是false,如果设置为true会自动将为空的值过滤,只输出不为空的值。</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="excludeNullProperties">true</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="excludeNullProperties">true</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.3. ignoreHierarchy 参数:表示是不是纰漏等级,也就是继承关系,好比:TestAction继承于BaseAction,那么TestAction中归回的json字符串默 认是不会包含父类BaseAction的属性值,ignoreHierarchy值默认为true,设置为false后会将父类以及子类的属性一起归回。</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="ignoreHierarchy">false</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="ignoreHierarchy">false</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.4. includeProperties 参数:输出结果中需要包含的属性值,这搭正则表达式以及属性名匹配,可以用“,”分割填充多个正则表达式。</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 如:输出person的所有属性</span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <param name="includeProperties">person.*, person\.name</param></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </span><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> </result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> <result type="json"><param name="includeProperties">person.*, person\.name</param></result></span><wbr style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><br style="text-align:left; line-height:21px; font-family:tahoma,arial,宋体,sans-serif; color:rgb(51,51,51); font-size:14px"><span style="font-family:tahoma,arial,宋体,sans-serif; color:#333333; text-align:left; line-height:21px; font-size:14px"> 5.5. excludeProperties 参数:输出结果需要剔掉的属性值,也支持正则表达式匹配属性名,可以用“,”分割填充多个正则表达式,大致相同4.4.</span></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
相关推荐
在处理JSON(JavaScript Object Notation)时,Struts2提供了强大的支持,使得前后端的数据交换更加便捷。JSON是一种轻量级的数据交换格式,易于人阅读和编写,同时也易于机器解析和生成。它被广泛应用于Ajax(异步...
请求的目标是一个Struts2 Action,Action处理完业务逻辑后,通过JSON返回数据。 为了实现这一功能,Action类需要包含将要序列化成JSON的属性,并且需要配置对应的Action Mapping。在struts.xml配置文件中,你可以...
在Java世界里,`json-lib-2.1.jar` 是一个用于处理JSON的库,它提供了一系列的方法来将Java对象转换为JSON格式,以及将JSON字符串反序列化回Java对象。这个库支持多种Java类型,包括基本类型、集合、Map、自定义Java...
该插件包含处理JSON相关的类库,使得Struts2能够识别并处理JSON格式的数据。具体来说,插件中的`struts-plugin.xml`配置文件定义了一个名为`json-default`的包,其中包含了`JSONResult`和`JSONInterceptor`两种结果...
`struts2-json-plugin`是Struts2的一个插件,它使得Struts2能够处理JSON请求和响应,无需额外的配置或库。这个插件不仅包含了源码,还包含了必要的配置文件和类,使得开发者可以深入理解其工作原理并进行自定义扩展...
在本文中,我们将探讨两种在Struts2框架中返回JSON数据的方法。...二是利用Struts2的内置JSON插件,通过返回特定的属性和结果类型自动处理JSON。每种方法都有其适用场景,可以根据项目需求选择合适的方式。
安装插件后,只需在Action配置中启用JSON支持,就能自动处理JSON输出。 2. **Action配置**: 在Struts2的配置文件(struts.xml或struts.properties)中,需要为Action添加一个`@ResultType`注解或结果类型配置,指定...
这个插件主要的功能是让Struts2应用程序能够轻松地处理JSON(JavaScript Object Notation)数据格式,使得Web应用可以方便地进行JSON序列化和反序列化,从而实现与前端的Ajax交互。 Struts2是一个基于Model-View-...
1. **服务端**:在Struts2的Action类中,定义一个方法处理请求,该方法可能需要访问数据库或其他业务逻辑,然后将结果转化为JSON对象。通过配置struts.xml,设定这个方法返回JSON类型的结果。 2. **客户端**:在...
- `jackson-*.jar` 或 `gson-*.jar`:这两个库提供了JSON对象和Java对象之间的自动转换,Struts2可以与它们集成,使得JSON处理更加便捷。 4. **Servlet容器相关库**:由于Struts2是基于Servlet API的,因此需要`...
总之,"struts2-json-lib"提供了实现Struts2和JSON整合所需的全部组件,简化了在Java Web应用中处理JSON数据的过程。正确地配置和使用这些库,可以大大提升开发者的生产力,让Web应用具备更强大的数据交互能力。
1. **Struts2 JSON插件**:Struts2提供了内置的JSON插件,允许我们直接将Action的返回值转换为JSON格式。安装并配置该插件后,只需在Action类的方法上添加`@Result(type="json")`注解,即可启用JSON响应。 2. **...
3. JSON处理库:`json-lib.jar`(通常在Struts2的JSON插件中已经包含) 确保这些库被添加到项目的类路径中,以便Struts2能够解析并返回JSON数据。 **二、编写页面** 在前端,我们需要一个使用Ajax的HTML页面。...
在Struts2中,我们可以通过Action类返回一个JSON结果类型,这样Struts2会自动将Action的属性转化为JSON格式并返回给客户端。客户端通常使用JavaScript库如jQuery来接收并处理这些数据。 在描述中提到的"以JQuery...
在Struts2中集成JSON,可以方便地将服务器端处理的结果以JSON格式传递给前端,简化数据传输并提高应用性能。 一、Struts2与JSON集成的必要性 在传统的Web开发中,服务器通常返回HTML页面来更新客户端视图。然而,...
- 配置Struts2的配置文件(struts.xml或struts-default.xml),添加JSON插件的配置,以便让Struts2框架知道如何处理JSON相关的Action。 - 确保Action类中有相应的getter和setter方法,以便JSON插件能够正确地序列化...
Struts2的JSON插件正是为了方便开发者在Struts2框架中处理JSON数据而设计的。 首先,让我们深入了解JSON。JSON是一种独立于语言的数据交换格式,具有易于人阅读和编写,同时也易于机器解析和生成的特点。它的数据...
在本场景中,我们将探讨如何使用AJAX来传递JSON数组,并在Struts2的Action中接收和处理这些数据。 首先,JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,它易于人阅读和编写,同时也易于机器解析...
`struts.action.extension`设置允许请求的扩展名包含`json`,表示可以处理JSON请求。 在Action类中,我们可以这样返回JSON: ```java public class MyAction { public Map, Object> execute() { Map, Object> ...