日期:2014-05-17 浏览次数:20840 次
觉得json就是一种存放数据的东西,用它存放后js更容易解析。jquery是个方便产生特效的东西。我想写实例来验证他们。先写个验证json的。我的想法是:public class student { // bean
private int id;
private String name;
//get & set
...
}
@Controller
public class StudentController {
@requstmapping("/allstudent")
@ModelAttribute("users")
public List<student> getAll() {
List<student> all = new ArrayList<student>();
for ( ...) {
student bean = new student(); //new bean
bean.setid(...); // build bean
bean.setname(...);
all.add(bean);
}
return all; // json
}
}
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'id', type: 'int'}
]
var store = var myStore = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url: 'server_path/context_path/allstudent',
reader: {
type: 'json',