layui date 动态添加的日期怎样渲染

2025-05-19 12:17:32
推荐回答(1个)
回答1:

1、首先前台用Ajax,其中注意dataType一定要选择json方式,Action成功返回给页面的Json内容是这样的[{"number":"V006","names":"LiLei"}],可见comment['names']对应"names":"LiLei",comment['number']对应"number":"V006"。

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

$.ajax({
type: "post",
url:'apply/mystudent.action?',
cache: false,
dataType : "json",
success: function(data){

$.each(data, function(commentIndex, comment){

alert("姓名"+ comment['names']);

alert("学号"+comment['number']);

});
}
});

2、Ajax的URL指向在java的action中mystudent方法,返回的list其实是一个对象Student,包括了names和nunmber字段

?

1
2
3
4
5
6
7

public String mystudent() throws Exception{
List list=priceService.query();//调用接口实现类

this.jsonUtil(list);

return null;