Recently, when jquery is used for asynchronous requests, the request is successful, but the correct JSON result cannot be returned. Call the error function with the object returned by jquery. getjson () and obtain "parsererror" with the alert error message ". Since the results were returned correctly before, after modifying the method name in the action, the method suddenly fails unexpectedly. This project is relatively large and complex. if an exception is thrown, the page will jump to the error page. However, when an asynchronous request is used, the callback function cannot be executed, so the error information cannot be located, but it was determined that there was an error during serialization, so the attribute that does not need to be serialized was added
@ JSON (serialize = false) annotation, but still fails. Locate the action on the error page and set the breakpoint and analyze the exception. invocationtargetexception is obtained, which proves that the previous speculation about serialization is correct. But why is it still a serialization error? Check the code carefully and find that the logic function name starts with get when modifying the method, which leads to the serialization of success returned by the function. Rename the method name. If it does not start with "get", restart the server and run it. The result is completely correct. When JSON is used in the summary action, only the attribute method uses get settings. Other logical methods do not start with get. Otherwise, serialization exceptions may occur.