function test(){var store2=new Ext.data.Store({proxy : new Ext.data.HttpProxy({url : 'job/job_do!getflag.action'}),reader : new Ext.data.JsonReader({root : 'flag',totalProperty : 'count2'},[{name:'teachdoc'}]),remoteSort : true});store2.load({params : {start : 0,limit : 12}});for(var i=0;i<store2.getCount();i++){ var record=store2.getAt[i];Ext.Msg.alert('xa',record.get('teachdoc'));}}后臺action中的方法如下:public String getflag()throws Exception{//long id = RequestUtil.getIntParameter(req, "workId", 0);long teach_id = ((Teachers) req.getSession().getAttribute("teacher")).getTeachId();StringBuffer sb = new StringBuffer();// TbSubTeacherStatic model = new TbSubTeacherStatic();sb.append("{\"count2\":" + 1 + ",");sb.append("\"flag\":[");long s=this.jobDao.getflag(teach_id);sb.append("flag:\n[");sb.append("{"+"\"teachdoc\":\"" + String.valueOf(s)+ "\"}");sb.append("]}"); res.setCharacterEncoding("UTF-8");res.getWriter().print(sb.toString());return null;}
前端有如下函數(shù)接受json,可沒接受到,請高手看看,這樣寫對嗎?
慕標琳琳
2023-02-17 21:17:12