js端:
$(function(){
$.ajax({
url : '<c:url value="/app/doFindAPPMarketList.do"/>',
data : {
},
type : "POST",
dataType : "json",
success : function(data) {
var appList = data["appList"];
var userList = data["userList"];
for(var i = 0; i < appList.length; i++){
$(".getAppListClass").append("<option value='"+appList[i]["appid"]+"'>"+appList[i]["name"]+"</option>");
}
for(var i = 0;i < userList.length; i++){
$(".getAppMarketListClass").append("<option value='"+userList[i]["userId"]+"'>"+userList[i]["nickname"]+"</option>");
}
},
error : function(e) {
alert(e);
}
});
});
java 端:
public void doFindAPPMarketList(){
List<AppDto> appList = this.appService.doFindAll();
List<UserDto> userList = userService.doFindUsers();
JSONObject json = new JSONObject();
json.put("appList", appList);
json.put("userList", userList);
try {
response.setContentType("text/json; charset=utf-8");
response.getWriter().write(json.toJSONString());
response.getWriter().flush();
} catch (IOException e) {
e.printStackTrace();
}
}