快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

和记娱乐博娱188_机器人论坛



这是action页面,

package tester.business.maitain;

import tclcc.tester.util.Selector;

import org.apache.struts.action.*;

import javax.servlet.http.*;

import java.util.*;

import org.apache.struts.upload.FormFile;

import java.io.*;

public class MaintainAction

extends Action {

public ActionForward execute(ActionMapping actionMapping,

ActionForm actionForm,

HttpServletRequest httpServletRequest,

HttpServletResponse httpServletResponse) {

/**@todo: complete the business logic here, this is just a skele和记娱乐博娱188ton.*/

M和记娱乐博娱188aintainForm maintainForm = (MaintainForm) actionForm;

TrainPlanDAO trainPDAO = new TrainPlanDAO();

Trainplan trainPlan = new Trainplan();

trainPlan = maintainForm.getTrainPlan();

FormFile theFile = null;

theFile = maintainForm.getTheFile1();

String p_accessory;

p_accessory = theFile.getFileName();

try {

InputStream stream = theFile.getInputStream(); //把文件读入

String filePath = httpServletRequest.getRealPath("/"); //取当前系统路径

ByteArrayOutpu和记娱乐博娱188tStream baos = new ByteArrayOutputStream();

OutputStream bos = new FileOutputStream(filePath + "\\sub" + "/" +

theFile.getFileName()); //建立一个上传文件的输出流

//System.out.println(filePath+"/"+file.和记娱乐博娱188getFileName());

int bytesRead = 0;

byte[] buffer = new byte[8192];

while ( (bytesRead = stream.read(buffer, 0, 8192)) != -1) {

bos.write(buffer, 0, bytesRead); //将文件写入办事器

}

bos.close();

stream.close();

} catch (Exception e) {

System.err.print(e);

}

try {

trainPlan.setP_accessory(p_accessory);

trainPDAO.addTrainPlan(trainPlan);//调用数据库插入措施

System.out.println("success");

} catch (Exception ex) {

}

httpServletRequest.setAttribute("trainPlain", trainPlan)和记娱乐博娱188;

return (actionMapping.findForward("trainplanCreated"));

}

}

您可能还会对下面的文章感兴趣: