map. The put (" 46 ", "daf");
The map. The put (" a2 ", "daf");
The map. The put (" 3 ", "daf");
The map. The put (" e1 ", "333");
Expect output in the above order, as a result, unlike expectations,
How to deal with this problem?
The code is as follows:
1, the controller
@ RestController
@ RequestMapping ("/test ")
@ Api (tags={} "test map", the description="test map111")
Public class TestController {
@ PostMapping ("/test ")
@ ApiOperation (" MAP ")
Public ResultBody
2, ResultBody
@ Data
@ AllArgsConstructor
@ NoArgsConstructor
Public class ResultBodyImplements the Serializable {
private String code;
Private String MSG.
Private T data;
Public ResultBody (String code) {
This. Code=code;
This. MSG=the ResultCode. SELECT_SUCCESS. GetCode ();
}
Public ResultBody (String code, String MSG) {
This. Code=code;
This. MSG=MSG;
}
Public ResultBody (T data) {
This. Code=the ResultCode. SELECT_SUCCESS. GetCode ();
This data=https://bbs.csdn.net/topics/data;
This. MSG=the ResultCode. SELECT_SUCCESS. GetMsg ();
}
Public static ResultBody success () {
Return new ResultBody (the ResultCode. SELECT_SUCCESS. GetCode ());
}
Public static ResultBody success (Object data) {
Return new ResultBody (data);
}
Public static ResultBody fail () {
Return new ResultBody (the ResultCode. SELECT_ERROR);
}
Public static ResultBody fail (String code, String MSG) {
Return new ResultBody (code, MSG);
}
Public static & lt; T> ResultBodyFailed (IErrorCode errorCode) {
Return new ResultBody(errorCode. GetCode (), errorCode. GetMsg (), null);
}
}
CodePudding user response:
That use LinkHashedMapCodePudding user response:
LinkHashedMap used, no matter use, I guess is a problem of Jackson, but don't know how to solve,CodePudding user response:
1. Yourself into a string to the front desk, the automatic conversion of theno spring2. Change the data structure, with the list