When using struts2 JSON-plugin, if you want to serialize an action, you should block attributes that do not need to be serialized, such as Dao.
Especially Dao, if not blocked, it will cause
The following error occurs:
Org. Apache. struts2.json. jsonexception: Java. Lang. Reflect. invocationtargetexception
Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Org. apache. struts2.json. jsonexception: Java. lang. reflect. invocationtargetexceptionpache. struts2.json. jsonexception:
The blocking method is simple: do not set getter for the attribute to be blocked.
Or add the annotation @ JSON (serialize = false) before the getter of the property to be blocked.
Java code
@ JSON (serialize = false)
Public userdao getuserdao (){
Return userdao;
}