MasterofProject

Struts2+AJAX access to JSON data

label Struts2.0AJAXframeJava
266 people read comment(1) Collection report
Classification:


        I met a bug last night, the method is called Ajax Struts2 inside the method to get the JSON problem, although now that the problem has not been resolved, but a variety of Baidu, found that the interaction between stuts2 and Ajax understanding and deep.


One, if you set the Action to return the result for the JSON type


                


   As above, if you want this action to return the results for the JSON, the first to specify Bao Jicheng as json-default, after which, in the result, indicating the JSON "type="".


<result> nodes can also be added to the param parameter to specify the serialization parameters: where to start serialization, serialization, who do not serialization... For example, the configuration of the root node is success, if not configured, it will be the default serialization Action all provide get*** () method of attribute. If you make it, you start down the root from the start.


Two, some of the commonly used Action configuration


      If no root is configured in the configuration file, you can do it in a way that does not require serialization:


            


           With this comment, the get** () is ignored. In addition, the @JSON can also specify the format of serialization, the name of the.

      

Three, to achieve the object of the Serializable interface


       General serialization will be the default serialization of the get method provided by the member variables. But you can specify the attributes that do not need to be specified by the keyword transient.


             

           But for the implementation of the Externalizable interface class, this keyword is useless.

      

Four, some of the pit struts2+ajax


                          1, each error, strtus2 error page will return to Ajax, and Ajax methods into success, even so is the wife?) B..

2, for the novice, not familiar with the JSON, and can not see the JSON specific conversion process, people can only rely on speculation when the time of the report is wrong.

            

 

       



top
Zero
step on
Zero
Guess you're looking for
View comments
* the above user comments only represent their personal views, does not represent the views or position of the CSDN website
    personal data
    • visit301409 times
    • Integral:Twelve thousand one hundred and sixty-two
    • Grade
    • Rank:591st name
    • original334
    • Reproduced:6
    • Translation:0
    • Comments:4350 article
    Blog column
    Classification of articles