Configuration view in spring XML if it is the following
< Propertyname= "Defaultviews"> <List> <Beanclass= "Org.springframework.web.servlet.view.json.MappingJackson2JsonView"> </Bean> </List> </ Property>
Then the return result will be:
{"Commonajaxresponse": {"code": 1, "ErrorCode":null, "errormessage":null, "data": {"key": "123"}}}
One of the commonajaxresponse is not what we want.
Note The API description of the Mappingjackson2jsonview property Extractvaluefromsinglekeymodel, which can be set to true to resolve.
< Propertyname= "Defaultviews"> <List> <Beanclass= "Org.springframework.web.servlet.view.json.MappingJackson2JsonView"> < Propertyname= "Extractvaluefromsinglekeymodel"value= "true" /> </Bean> </List> </ Property>
Get:
{"Code": 1, "ErrorCode":null, "errormessage":null, "data": {"key": "123"}}
How the JSON returned by Spring MVC goes to the root node name