我有简单的flex aplication,它读取XML文件并在dataGrid中显示。我在更改XML文件时遇到问题,因此Chrome刷新后不会刷新此XML数据,即使重新启动Chrome也不行。我认为XML数据会留在Chrome缓存中吗?
如何自动刷新这些数据?在firefox功能中都正确..
我的灵活代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="aktualityService.send()">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
private var xmlData:ArrayCollection;
protected function aktualityService_resultHandler(event:ResultEvent):void
{
xmlData = new ArrayCollection();
for each (var aktualita:Object in event.result.aktuality.aktualita)
{
xmlData.addItem(aktualita);
}
}
protected function aktualityService_faultHandler(event:FaultEvent):void
{
Alert.show("ERROR read xml: " + event.fault.faultString);
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="aktualityService"
url="data/aktuality.xml"
result="aktualityService_resultHandler(event)"
fault="aktualityService_faultHandler(event)"
method="GET"/>
</fx:Declarations>
<s:DataGrid id="dataGridId"
y="100" x="0" dataProvider="{xmlData}" />
</s:Application>
然后我在Flash Builder中导出发布版本并复制到我的服务器。
答案 0 :(得分:3)
要防止缓存,请在文件路径后使用随机数,如:
<s:HTTPService id="aktualityService"
url="data/aktuality.xml?{UIDUtil.createUID()}"
result="aktualityService_resultHandler(event)"
fault="aktualityService_faultHandler(event)"
method="GET"/>