Ext.form.Combobox后台传xml别忘记了 response.setContentType("text/xml");

今天被Ext.form.Combobox玩能了半天,后来发现原来后台少了这个: response.setContentType("text/xml");

 

	var Employee = Ext.data.Record.create([
		{ name : 'id',  mapping : 'id' }, 
		{ name : 'name', mapping : 'name' }, 
		{ name : 'occupation' } 
	]);
	
	var myReader = new Ext.data.XmlReader({
			totalRecords : "results", 
			record : "row", 
			id : "id"
		}, Employee);

	store_featureClass = new Ext.data.Store({
		url : 'http://127.0.0.1:8080/WebTemplate_Struts_IBatis/ext/extTestAction.do?method=sendDataToExt',
		//url: 'http://127.0.0.1:8080/WebTemplate_Struts_IBatis/extTest/sale/sale.xml',
		method : 'GET',
		reader : myReader
	});
	combo_featureClass = new Ext.form.ComboBox({
		store: store_featureClass,
		width: 100,
		displayField: 'name',
		valueField: 'id',
		triggerAction: 'all',
		mode: 'remote',
		//applyTo: 'featureClassInput'
		renderTo: 'featureClassDiv'
	});	

 servlet:

 PrintWriter out = response.getWriter();
        response.setContentType("text/xml");


        String ret = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
        ret += "<dataset>";
        ret += "	<results>2</results>";
        ret += "	<row>";
        ret += "		<id>1</id>";
        ret += "		<name>Bill</name>";
        ret += "		<occupation>Gardener</occupation>";
        ret += "	</row>";
        ret += "	<row>";
        ret += "		<id>2</id>";
        ret += "		<name>wv</name>";
        ret += "		<occupation>Gasdf</occupation>";
        ret += "	</row>";
        ret += "</dataset>";
        out.print(ret);
        out.flush();
        return null;

 

真让哭笑不得啊!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值