I know that Struts2 JSON Plugin converts whole Action
class into JSON form and by supplying a root
param
we can let it convert only one param
into JSON form.
What if I want out of 5 members of my action class, only 2 or 3 of my members to be converted to JSON? Is this possible?
You can use includeProperties
or excludeProperties
.
IncludeProperties
didn't worked as expected in my case & hence, I prefer using exludeProperties
instead.
The action configuration will look like
<action name="camp/ls" class="actions.MyAction">
<result type="json">
<param name="excludeProperties">
dataIsp,deviceBlacklist,deviceOs,deviceWhitelist,exchanges
</param>
</result>
</action>