Ext上传文件,上传的文件报空指针异常

Ext上传文件,上传的文件报空指针异常

问题描述:

如题:
我上传一个文件,但是他却报空指针异常哈,我试了!=null和==null都不发输出
后来打印是空指针异常
我的JSP代码:
xtype: 'fileuploadfield',
id: 'news_img',
emptyText: '请选择图片...',
fieldLabel: '图片上传',
name: 'imgFile',
allowBlank:true
我在action里已经有个属性 File imgFile,并有他的get和set方法

客户端报错还是服务端报错

fileuploadfield是2.2的plugin吧,要看下源码说明

http://www.17ext.com/showtopic-1354.aspx 你参考这个吧,我改写的

fileUpload : Boolean 要设定你的form为fileUpload:true
Set to true if this form is a file upload. File uploads are not performed using normal 'Ajax' techniques, that is the...
Set to true if this form is a file upload.

File uploads are not performed using normal 'Ajax' techniques, that is they are not performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the DOM

element temporarily modified to have its target set to refer to a dynamically generated, hidden which is inserted into the document but removed after the return data has been gathered.

The server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON to send the return object, then the Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.

Characters which are significant to an HTML parser must be sent as HTML entities, so encode "<" as "<", "&" as "&" etc.

The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a responseText property in order to conform to the requirements of event handlers and callbacks.

Be aware that file upload packets are sent with the content type multipart/form and some server technologies (notably JEE) may require some custom processing in order to retrieve parameter names and parameter values from the packet content.