This article for you to introduce the next by adding a background list to the front select tag to assign values, specific code as follows, interested friends can refer to the HA
copy code code 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 Code code as follows:
public void Finduserlist () throws IOException {
list<usermodel> roleuserlist = Userservice.finduserlist ();
String json = Jsonarray.fromobject (roleuserlist). toString ();
writehtml (JSON);;
}
Copy Code code 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);
}
}