Programımın istemci tarafını oluşturmak için ExtJS kullanıyorum. Sunucuya bir Ajax isteği göndermek ve yanıt dosyasını (ikili dosya, düz metin dosyası, yani XLS veya PDF) almak istiyorum bir durum var. Bu döndürülen dosyayı ExtJS tarafından nasıl alabilirim (Bu dosya indirilip istemciye kaydedilebilir)? Yanıtı almak için var result = Ext.decode(response.responseText)
kullanamıyorum çünkü yanıt ikili veri içeriyor ve kodu çözülemiyor.Yanıt kütüğü kullanma ExtJS
Ajax çağrısı çok basit:
public void sendFile(HttpServletResponse response, String filePath) {
def file = new File(filePath);
response.setContentType("application/octet-stream");
response.setHeader("Content-disposition", "attachment;filename=${file.getName()}");
response.outputStream << file.newInputStream();
}
Çok teşekkür ederim:
Ext.Ajax.request({
url : 'myController/exportFile',
method : 'GET',
success : function(response, opts) {
// What should I do to get the file?
},
failure : function(response, opts) {
alert('Export file failed!')
}
});
İşte dosya dönmek için benim sunucu eylemdir!
Harika yanıt! Sen en iyisin !! Bu kadar uzun zamandır baktım ve sadece bu yazı bana doğru cevabı verdi! – davs
@amol Lütfen bana yardım edin (burada) (http://stackoverflow.com/questions/8505995/itextsharp-generated-pdf-how-to-prompt-a-user-to-choose-where-to-save) – Armance