Home > Net >  LayUI> Table component to the WebApi interface by value problem!
LayUI> Table component to the WebApi interface by value problem!

Time:03-31

The front-end code
 
//initial parameters
Var parameter={
'list_TerminalType: null,
'list_TerminalGroup: null,
'TerminalName' : 'wait',
'TerminalIP: null
};
//form initialization
Var table_Terminal=table. Render ({
Elem: '# table_Terminal',
contentType: "application/json; Charset=utf-8;" ,
url: '../../../API/Terminal/GetList_Terminal ',
Where: parameter,
Method: "post",
The toolbar: '# toolbar_Table_Terminal_Add',
DefaultToolbar: [' filter ', 'exports',' print '{
Title: 'prompt',
LayEvent: 'LAYTABLE_TIPS',
Icon: 'layui - icon - tips'
},
Cols: [[
{type: "checkbox", width: 50, unresize: true, align: 'center'}
]],
Page: true,
Limits: [10, 15, 20],
Limit: 10,
Even: true,
ParseData: function (returnData) {//res is the original data returned by the
If (returnData Code_State==1) {
ReturnData. Code_State=0;
Var ShowData;
If (this. Page. Curr) {
ShowData=https://bbs.csdn.net/topics/returnData.Data.slice (this limit * (this. Page. Curr - 1), enclosing limit. * this page. Curr);
}
The else {
ShowData=https://bbs.csdn.net/topics/returnData.Data.slice (0, enclosing limit);
}
Return {
"Code" : returnData Code_State,//interface state
"MSG" : returnData Err_Msg,//parsing tooltip text
"Count" : returnData. Data. Length,//parse the Data length (inkpad error - & gt; Length can be ignored)
"Data" : ShowData//parse the data list
};
}
The else {
Return {
"Code" : 0,//interface state
"MSG" : 0,//parsing tooltip text
"Count" : 0,//parse the data length (inkpad error - & gt; Length can be ignored)
"Data" : returnData. Data//parse the data list
};
}
}
});



The backend interface code
 
[HttpPost]
Public JsonTemplate GetList_Terminal ([FromUri] GetList_Terminal parameter)
{
List List_Data=https://bbs.csdn.net/topics/new List ();
JsonTemplate Jsontemplate;
//GetList_Terminal parameter=JsonHelper. JsonToModelInt codeState;
String errMsg;


CodeState=Result. Ok;
ErrMsg=ApiErrStr. Ok;
Jsontemplate=new JsonTemplate (codeState, errMsg, list_Data);
Return jsontemplate;
}



The backend API interface cannot receive the parameters. Received all is null!!!! Ask the great spirit show ~ ~


CodePudding user response:

Fromuri into frombody try

CodePudding user response:

Pray god to give directions, really don't want to? This way of passing parameters!!!!!!

CodePudding user response:

To [FromBody] tried, no good!

CodePudding user response:

What version of the backend with [FromBody] changed

CodePudding user response:

If use the webapi you just need to add [ApiController] at the controller head

CodePudding user response:

reference 5 floor Null_Reference reply:
if used webapi you just need to add [ApiController] at the controller head

Remove the [fromurl]


Or do not add apicontroller, fromuri into frombody

CodePudding user response:

reference 4 floor Null_Reference response:
what version of the backend with changed? [FromBody]

To mend the interface returned directly call the Error

CodePudding user response:

The front catch package see submit data structure
  • Related