我正在使用相同的插件,对我来说效果很好。我在您的代码中看到的第一个问题是您尚未设置要提交的上传按钮的类型。
<button id="px-submit" type="submit">Upload</button>
希望这应该解决null指针除外。另外,如该插件的文档中所述,您需要返回一个json字符串
<div id='message'>success message</div>
成功上传。因此,您需要更改struts.xml映射。尝试此操作,如果您遇到任何其他问题,请立即与我联系。编辑:好的,这是您要求的我的代码
JSP
<form action="uploadImage" method="post" enctype="multipart/form-data"> <input type="file" name="image" multiple/> <button id="px-submit" type="submit">Save all images</button> <button id="px-clear" type="reset">Clear all</button></form>$('.fileUpload').fileUploader({ autoUpload: false, buttonUpload: '#px-submit', buttonClear: '#px-clear',});动作课
您需要返回流结果。我使用的插件(struts2的jQuery插件),它采用的是变化很好地照顾,但你 不
必须使用它仅仅是因为这一要求,而不是我给你返回流结果的代码,而无需使用任何插件。(摘自从这里)
public class UploadImageAction extends ActionSupport{ private File image; private String imageContentType; private String imageFileName; //getter/setter for these public String execute() { String status=""; try{ //save file pre here status="<div id='message'>successfully uploaded</div>"; //on success inputStream = new StringBufferInputStream(status); }catch(WhateverException e){ status="<div id='status'>fail</div><div id='message'>Your fail message</div>"; //on error inputStream = new StringBufferInputStream(status); //other pre } return SUCCESS; } private InputStream inputStream; public InputStream getInputStream() { return inputStream; }}struts.xml
<action name="fileUpload" > <result type="stream"> <param name="contentType">text/html</param> <param name="inputName">inputStream</param> </result> </action>



