您的位置:首页 > 编程语言 > Java开发

struts2+uploadify整合后报错error 404

2016-05-28 18:54 405 查看

问题概述

在项目中应用了struts2和uploadify来完成上传文件的功能,但是在开发过程中发现uploadify在上传文件后,会报http 404 error的错误,认真检查struts2的action路径后确认不是路径错误的问题。然后在网上找到一些对于这个问题的解决办法,有的说是session id丢失问题,有的说是uploadify的bug,需要修改uploadify的源码。在尝试了各种解决方案后,都以失败告终。

最后只能打开uploadify和struts2的调试模式,输出调试信息检查原因。然后在调试信息中发现了原来uploadify的上传控件名为fileData,然后将strust2的上传action类的成员变量名改为fileData后,问题解决。

开发环境:

jdk1.7

struts 2.3.16

uploadify 3.2.1

Action类代码:

@ParentPackage("json-default")
@Namespace(value="/bpmapp/portal/component")
public class WfAttachmentAction extends ActionSupport {
private String docId;
private String attachmentId;
//变量名称必须要为fileData,其他都会报错
private File fileData;
private String fileDataFileName;
private String fileDataContentType;

public String getDocId() {
return docId;
}

public void setDocId(String docId) {
this.docId = docId;
}

public File getFileData() {
return fileData;
}

public void setFileData(File fileData) {
this.fileData = fileData;
}

public String getFileDataFileName() {
return fileDataFileName;
}

public void setFileDataFileName(String fileDataFileName) {
this.fileDataFileName = fileDataFileName;
}

public String getFileDataContentType() {
return fileDataContentType;
}

public void setFileDataContentType(String fileDataContentType) {
this.fileDataContentType = fileDataContentType;
}

public String getAttachmentId() {
return attachmentId;
}

public void setAttachmentId(String attachmentId) {
this.attachmentId = attachmentId;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: