- 爱易网页
-
JavaSript
- Struts2处置json简介及注意事项
日期:2014-05-16 浏览次数:20343 次
Struts2处理json简介及注意事项
-
action
中:??
-
????private??List<Admins>?entities;??
-
????private?Admins?admin;??
-
????public
?Admins?getAdmin()?{??
-
????????return
?admin;??
-
????}??
-
????public
?List<Admins>?getEntities()?{??
-
????????return
?entities;??
-
????}??
-
????public
?String??
execute
(){??
-
????????AdminsService?asi?=?new?AdminsServiceImpl();??
-
????????entities?=?asi.getObjects(Admins.class);??
-
????????admin??=?(Admins)?asi.findObjectById(Admins.class,?1);??
-
????}??
-
??
-
配置文件中的内容为??
-
形式1:??
-
<result?type="json"
>???
-
????<param?name
=
"root"
></param>???
-
</result>??
-
测试的结果为:??
-
{"admin"
:??
-
{"address"
:
null
,
"cellPhone"
:
null
,
"email"
:
null
,
"id"
:1,
"password"
:
"ssssssss1"
,
"realName"
:
"sss1"
,
"role"
:
null
,
"sex"
:
null
,
"userName"
:
"redarmy1"
},??
-
"entities"
:??
-
[{"address"
:
null
,
"cellPhone"
:
null
,
"email"
:
null
,
"id"
:1,
"password"
:
"ssssssss1"
,
"realName"
:
"sss1"
,
"role"
:
null
,
"sex"
:
null
,
"userName"
:
"redarmy1"
},??
-
{"address"
:
null
,
"cellPhone"
:
null
,
"email"
:<
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。