日期:2014-05-16  浏览次数:20508 次

struts2 对对象进行json化遇到的一些问题

? 今天在做struts2json处理的时候遇到一个奇怪的问题,我明明在action层中队对象进行了赋值处理,设置返回的类型为json,但是输出确实为空。

?

?private ProposalReply? reply;

?

?

? reply=proposalService.getproposalreply(session,this.getDocumentnumber(),unitusername);

?

public ProposalReply getReply() {
??return reply;
?}

?public void setReply(ProposalReply reply) {
??this.reply = reply;
?}

<!-- 取得指定提案的承办单位复文 -->
??<action name="getproposalreply" class="proposalListAction" method="getproposalreply">
???<result name="success" type="json">
???????? <param name="includeProperties">
????? reply

??????</param>
?????? ??</result>
??</action>?

?

?

返回的json则是为空,

{"reply":{}}

?

想了很久都想不明白,最后通过查找资料,在返回的json字符串中设置对象的指定属性就是了,如:

?

<param name="includeProperties">
????reply\.fullname,
????reply\.exetype,
????reply\.replynumber,
????reply\.replylevel,
????reply\.contactphonenumber,
????reply\.replydate,
????reply\.content,
????reply\.transactattitude,
????reply\.transactresult,
????reply\.recommendations
???</param>

这样接可以了,如果还有其他方式解决,望各位大侠不吝赐教。