Struts2+ajax+json

The problem of appsJson

            should be in the framework of struts2. For deeply nested objects, struts2 cannot perfectly format data in JSON format. As for why it can be done after removing the get method, it is because struts2 will format the data. The paragraph after your get method is treated as a field, such as getName(), he will find the name field in the class, and then format it as {name:"xxxxx"}, then if there is a getUser() method in the action, struts2 will find the user object in the action, and then format it. At this time, a user object will be nested in an action object, and struts2 will not be able to format it well, so there will be this error. You can also use get Annotate the method: @JSON(serialize = false), which tells struts2 to ignore this method.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326985144&siteId=291194637