日期:2014-05-17 浏览次数:20656 次
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',