ajax制作新闻网站,在ajax中使用json生成新闻页面

//实体类新闻

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 list=dao.findtitle();

request.setAttribute("list", list);

request.getRequestDispatcher("New.jsp").forward(request, response);

//response.sendRedirect(contextPath+"New.jsp");

out.flush();

out.close();

}

//jsp页面

$(function(){

function intinews(){//使用ajax技术获取新闻列表数据

$.ajax({

"url"         :"NewServlet",

"type"        :"post",

"dataType"    :"json",

"success"     :preosn

});

}

function preosn(data){

var $newlist=$("#news").empty();

for(var i=0;i

$newlist.append(data[i].en_title+"内容:"+data[i].en_content+"")

}

}

intinews();//执行新闻列表初始化工作

});

我这边运行了但它不报错错,可就是在页面上没有加载出来,不知懂怎么回事了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值