81,092
社区成员
发帖
与我相关
我的任务
分享
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>上传附件</title>
</head>
<body>
<form action="upload.action" method="post" enctype="multipart/form-data" >
标题:<input type="text" name="title" value=""><br><br><br><br>
<input type="file" name="file"><br>
<input type="file" name="file"><br>
<input type="file" name="file"><br>
<input type="submit" value="上传"/>
</form>
</body>
</html>
public class UploadAction extends ActionSupport {
private String title;
private File[] file;
private String[] fileContentType;
private String[] fileFileName;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public File[] getFile() {
return file;
}
public void setFile(File[] file) {
this.file = file;
}
public String[] getFileContentType() {
return fileContentType;
}
public void setFileContentType(String[] fileContentType) {
this.fileContentType = fileContentType;
}
public String[] getFileFileName() {
return fileFileName;
}
public void setFileFileName(String[] fileFileName) {
this.fileFileName = fileFileName;
}
public String upload(){
System.out.println(title);
System.out.println(file);
return SUCCESS;
}
}
<struts>
<package name="/upload" namespace="/custom/market/customer" extends="base">
<action name="upload" class="custom.market.customer.UploadAction" method="upload">
<interceptor-ref name="fileUpload"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/upload.jsp</result>
</action>
</package>
</struts>