怎么将从servlet拿到的list集合用json数据显示到jsp页面?
展开全部
可以这样做,返回类型为html格式,把集合显示做成单个页面(userlist.jsp),用div包含该页面,后台跳转到该页面,把div的html替换成返回来的html,页面:
<div id="list_div">
<jsp:include="userlist.jsp">
</div>
var submitUrl = "AdminMangeServlet";
$.ajax({
url: submitUrl,
type: "POST",
async: false,
cache: false,
globle: false,
dataType: "html",
beforeSend: function(XMLHttpRequest){},
success: function(data, textStatus){
$("#list_div").html(data);
},
error: function(XMLHttpRequest,textStatus,errorThrown){},
complete:function(msg){}
});
<div id="list_div">
<jsp:include="userlist.jsp">
</div>
var submitUrl = "AdminMangeServlet";
$.ajax({
url: submitUrl,
type: "POST",
async: false,
cache: false,
globle: false,
dataType: "html",
beforeSend: function(XMLHttpRequest){},
success: function(data, textStatus){
$("#list_div").html(data);
},
error: function(XMLHttpRequest,textStatus,errorThrown){},
complete:function(msg){}
});
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询