Copy codeThe Code is as follows:
$. Ajax ({
Url: "user! FindUserList. action ",
Type: "post ",
Success: function (data ){
Var jsonObj = eval ("(" + data + ")");
$. Each (jsonObj, function (I, item ){
JQuery ("# userList"). append ("<option value =" + item. userId + ">" + item. userRealName + "</option> ");
});
},
Error: function (text ){}
});
Copy codeThe Code is as follows:
Public void findUserList () throws IOException {
List <UserModel> roleuserList = userService. findUserList ();
String json = JSONArray. fromObject (roleuserList). toString ();
WriteHtml (json );;
}
Copy codeThe Code is as follows:
Protected void writeHtml (String strData ){
Try {
Response. setContentType ("text/html; charset = UTF-8 ");
PrintWriter pw = response. getWriter ();
Pw. write (strData );
Pw. flush ();
Pw. close ();
} Catch (IOException e ){
Log. error ("writeHtml ()", e );
}
}