第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在ajax中使用json生成新聞頁面

在ajax中使用json生成新聞頁面

qq_Dreamy_舊城_0 2017-07-12 12:12:12
//實體類新聞public class Easybuy_news { /** * 編號 */ private int en_id; /** * 標題 */ private String en_title; /** * 內容 */ private String en_content; /** * 錄入時間 */ private String en_create_time; public int getEn_id() { return en_id; } public void setEn_id(int enId) { en_id = enId; } public String getEn_title() { return en_title; } public void setEn_title(String enTitle) { en_title = enTitle; } public String getEn_content() { return en_content; } public void setEn_content(String enContent) { en_content = enContent; } public String getEn_create_time() { return en_create_time; } public void setEn_create_time(String enCreateTime) { en_create_time = enCreateTime; } public Easybuy_news() { // TODO Auto-generated constructor stub } public Easybuy_news(int enId, String enTitle, String enContent, String enCreateTime) { super(); en_id = enId; en_title = enTitle; en_content = enContent; en_create_time = enCreateTime; } }//servlet類public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); ? Easybuy_newsdao ?dao=new Easybuy_newsdaoimpl(); Easybuy_news ?news=new Easybuy_news();? List<Easybuy_news> list=dao.findtitle();? ? request.setAttribute("list", list); request.getRequestDispatcher("New.jsp").forward(request, response);? ? ? ? //response.sendRedirect(contextPath+"New.jsp"); out.flush(); out.close(); }//jsp頁面<script type="text/javascript">? ? ? ? ? ?$(function(){? ? ? ? ? ? ? ?function intinews(){//使用ajax技術獲取新聞列表數(shù)據(jù)? ? ? ? ? ? ? ?$.ajax({? ? ? ? ? ? ? ? ?"url" ? ? ? ? :"NewServlet",? ? ? ? ? ? ? ? ?"type" ? ? ? ?:"post",? ? ? ? ? ? ? ? ?"dataType" ? ?:"json",? ? ? ? ? ? ? ? ?"success" ? ? :preosn? ? ? ? ? ? ? ? ?});? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ?function preosn(data){? ? ? ? ? ? ? ? ? var $newlist=$("#news").empty();? ? ? ? ? ? ? ? ? for(var i=0;i<data.length;){? ? ? ? ? ? ? ? ? ? ? $newlist.append(data[i].en_title+"<span>內容:"+data[i].en_content+"</span>")? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ?intinews();//執(zhí)行新聞列表初始化工作? ? ? ? });? ? ?</script>? </head>??? <body>? ? ?<div id="news">? ? ??? ? ? </div>? </body>我這邊運行了但它不報錯錯,可就是在頁面上沒有加載出來,不知懂怎么回事了
查看完整描述

1 回答

已采納
?
小哈哈v

TA貢獻6條經(jīng)驗 獲得超4個贊

?data.length后面少了個i++。

查看完整回答
反對 回復 2017-07-15
  • 小哈哈v
    小哈哈v
    然后還有聲明變量也有問題。var $newlist=$("#news").empty(); 改成這樣: var $newlist=$("#news"); $newlist.empty();
  • qq_Dreamy_舊城_0
    qq_Dreamy_舊城_0
    為何要這樣呢
  • 1 回答
  • 2 關注
  • 2183 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號