日期:2014-05-16 浏览次数:20368 次
<!--<mvc:annotation-driven/> --> <!-- 这样配置的目地是了支持json数据的转换 --> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <util:list id="beanList"> <ref bean="mappingJacksonHttpMessageConverter"/> </util:list> </property> </bean> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean>
var schemaEnNameStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ url : '/ext_project/metaTable.action?method=querySchemaEnName', type : 'ajax' }), reader : new Ext.data.JsonReader({ root : 'root', type : 'json' }, [{ name : 'schemaEnName',mapping:'param' }]), autoLoad : false });
@RequestMapping(params = "method=querySchemaEnName") @ResponseBody public Object handleQuerySchemaEnName() { try { List<ParamDto> schemaEnNameList = metaTableService.querySchemaEnNameTotal(); Map<String,Object> map = new HashMap(); map.put("root", schemaEnNameList); map.put("success", true); return map; } catch (Exception e) { e.printStackTrace(); } return null; }
var tableEnNameStore = new Ext.data.JsonStore({ url : '/ext_project/metaTable.action?method=queryTableEnName', root : 'root', fields : [{ name : 'tableEnName',mapping:'param' }], autoLoad : false })
@RequestMapping(params = "method=queryTableEnName") public void handleQueryTableEnName(HttpServletRequest req,HttpServletResponse response){ try{ String schemaEnName = req.getParameter("schemaEnName"); List<String> list = metaTableService.queryTableEnNameBySchEnName(schemaEnName); List<ParamDto> tableEnNameList = new ArrayList(); Iterator iterator = list.iterator(); while(iterator.hasNext()){ ParamDto pDto = new ParamDto(); pDto.setParam((String)iterator.next()); tableEnNameList.add(pDto); } Map<String,Object> map = new HashMap(); map.put("root",tableEnNameList); map.put("success", true); JSONObject obj = JSONObject.fromObject(map); PrintWriter writer = response.getWriter(); writer.print(obj.toString()); }catch(Exception e){ e.printStackTrace(); } }
bean id="userListJson" calss="org.springframework.web.servlet.view.json.MappingJacksonJsonView" p:renderedAttributes="userList"/>
@requestMapping() public String **(ModelMap map){ List<User> list = new ArrayList<User>(); map.addAttribute("userList",list); return "userListJson" }