我正在尝试使用 struts2 上传文件但没有成功。我一直在关注 struts 2 展示指南,并且浏览了很多论坛。
这是我的 JSP
<form action="uploadFile" method="post" enctype="multiform/form-data">
<div class="overlay">
<div class="modal">
<div class="content">
<div class="headerText">Upload File</div>
<div class="fileuploadwindow">
<s:file id="upload" name="upload" label="File"/>
</div>
<div class="footerText" align="right">
<input type="button" class="aButton" value="Close"
onclick="closeCreate()"> <s:submit
class="aButton" value="Upload"/>
</div>
</div>
</div>
</div>
</form>
这是我的动作课
private File upload;
private String uploadFileName;
private String uploadContentType;
@Override
public String execute() throws Exception {
LOGGER.error("uploaded file : "+upload);
LOGGER.error("File name : "+uploadFileName);
LOGGER.error("content type : "+uploadContentType);
return super.execute();
}
@Override
public String input() throws Exception {
// TODO Auto-generated method stub
return super.input();
}
public String upload() throws Exception {
return SUCCESS;
}
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getUploadFileName() {
return uploadFileName;
}
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
public String getUploadContentType() {
return uploadContentType;
}
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
当我尝试上传文件时,出现异常
Error setting expression 'upload' with value '[Ljava.lang.String;@66fc92f'ognl.MethodFailedException: Method "setUpload" failed for object org.verientouch.opendrive.actions.UploadFileAction@61a8a328 [java.lang.NoSuchMethodException: org.verientouch.opendrive.actions.UploadFileAction.setUpload([Ljava.lang.String;)]
我也经历过Struts 2 文件上传空指针异常和struts2-cant-upload-file-invalid-field-value。但仍然没有成功
请建议我哪里错了