67,513
社区成员
发帖
与我相关
我的任务
分享
<form name="upload" action="upload.action" method="post" enctype="multipart/form-data">
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" class="bordercol_01">
<tr>
<td class="coltitle_01"></td>
</tr>
<tr>
<td height="40" align="center"><table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30%"> <input type="file" name="excelFile" /> </td>
<td width="70%"><input class="submit_01" type="submit" value="上 传" /></td>
<!--<td width="30%"><input type="text" name="name" label="username" ></td> -->
</tr>
</table>
</form>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="upload" class="com.wondersgroup.jxkh.dataimport.web.DataImpAction" method="uplodaFile">
<result name="success" >wel.jsp</result>
<result name="input" >wel.jsp</result>
</action>
</package>
</struts>
package com.wondersgroup.jxkh.dataimport.web;
import java.io.File;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionSupport;
import com.wondersgroup.jxkh.dataimport.bo.FileInfo;
import com.wondersgroup.jxkh.dataimport.service.DataImpService;
public class DataImpAction extends ActionSupport {
private File excelFile;
private HttpServletRequest req;
private DataImpService service;
public String uplodaFile(){
if(this.excelFile == null)
return INPUT;
FileInfo fileInfo = new FileInfo();
fileInfo.setFile(excelFile);
fileInfo.setFileName(excelFile.getName());
if(service.excelUpload(this.req,fileInfo)){
return SUCCESS;
}else{
return INPUT;
}
}
public File getFile() {
return excelFile;
}
public void setFile(File file) {
this.excelFile = file;
}
public HttpServletRequest getReq() {
return req;
}
public void setReq(HttpServletRequest req) {
this.req = req;
}
public DataImpService getService() {
return service;
}
public void setService(DataImpService service) {
this.service = service;
}
}