Im trying to retrieve data from DB using hibernate ORM and get the out-put as json result using Struts2. Everything work up to retrieving data from DB, but for the json res
Struts2 JSON plugin will serialize your whole action, including all the (non-transient) properties with a getter.
Since you are hiding your variables (definitely not a best practice, especially because it forces you to manually write every getter and setter... brr), and you have different names for the variable and for the getter, you are pointing the variable, but you should point the getter (then currency
instead of _currency
):
@Action(value = "currencies", results = {
@Result(name = "success",
type = "json",
params = {"includeProperties","currency\\[\\d+\\]\\..*"})
})
Also note that you can specify a root object, that is often preferred to the includeProperties
technique, as described here:
@Action(value = "currencies", results = {
@Result(name = "success",
type = "json",
params = {"root","currency"})
})