标签:style blog http color java 使用 io 文件 for
view层:
this.bbar = [{ xtype: ‘pagingtoolbar‘, //增加id id : ‘ptb‘, pageSize: 2, store: this.store, displayInfo: true, plugins: new Ext.ux.ProgressBarPager() }];
store层
1 Ext.define(‘Industry_Demo.store.Industry‘, { 2 extend: ‘Ext.data.Store‘, 3 /* 4 fields: [{name: ‘PK_Industry_ID‘,type: ‘int‘}, 5 {name: ‘Industry_Name‘,type : ‘string‘} 6 ], 7 */ 8 model : ‘Industry_Demo.model.Industry‘, 9 pageSize : 2, 10 //非常重要的属性 11 //autoLoad: {start : 0, limit : 2}, 12 proxy: { 13 type : ‘ajax‘, 14 enablePaging: true, 15 // url : ‘data/industries.json‘, 16 url : ‘/IndustryAdmin/getIndustries.do‘, 17 reader: { 18 type : ‘json‘, 19 root : ‘industries‘, 20 successProperty: ‘success‘, 21 totalProperty : ‘total‘ 22 23 } 24 } 25 /* 26 data : [ 27 {PK_Industry_ID:1,Industry_Name:‘aa‘}, 28 {PK_Industry_ID:2,Industry_Name:‘bb‘} 29 ] 30 */ 31 });
controller层
Ext.define(‘Industry_Demo.controller.Industry‘,{ //必须和文件同名 extend : ‘Ext.app.Controller‘, init : function() { // console.log("Hello"); this.control({ ‘industryList‘ : { itemdblclick: this.editRecord, render : function(myView){ myView.getStore().load({params:{start:0,limit:2}}); } },
后台代码springmvc+mybatis
@RequestMapping(value="/getIndustries",method=RequestMethod.GET) public void getIndustries(HttpServletRequest request,HttpServletResponse response){ String startString = request.getParameter("start"); String limitString = request.getParameter("limit"); int start = Integer.valueOf(startString); int limit = Integer.valueOf(limitString); System.out.println("select controller层"); System.out.println(start+" "+limit); int num = industryService.getIndustriesNum(); System.out.println(num+" "); List<Industry> list = null; list = industryService.getIndustries(start, limit); System.out.println("mission completed I am back"); String jsonString = "{success : true,total : "; jsonString +=num; jsonString +=",industries : ["; int i = 0; if(list.size()>0){ for(;i <list.size()-1;i++){ jsonString += "{id : "+ list.get(i).getId() + ",name : ‘"+list.get(i).getName()+"‘},"; } jsonString +="{id :" + list.get(i).getId()+",name : ‘"+list.get(i).getName()+"‘}]}"; } else{ jsonString = "{success : true,total : "; jsonString +=num; //jsonString +=",industries "; //jsonString +="{}]}"; jsonString += "}"; } try { response.getWriter().write(jsonString); } catch (IOException e) { // TODO Auto-generated catch block System.out.println("Something not good happen"); e.printStackTrace(); } }
标签:style blog http color java 使用 io 文件 for
原文地址:http://www.cnblogs.com/hzmbbbb/p/3936531.html