⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modifyrevertinfoaction.java

📁 一个oa系统
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.oa.companyculture.action;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import com.oa.companyculture.db.RevertInfoDao;
import com.oa.companyculture.db.Revertinfo;
import com.oa.companyculture.form.RevertInfoForm;

/** 
 * MyEclipse Struts
 * Creation date: 09-06-2007
 * 
 * XDoclet definition:
 * @struts.action path="/modifyRevertInfo" name="revertInfoForm" input="/companyculture/updaterevertinfo.jsp" scope="request" validate="true"
 * @struts.action-forward name="success" path="/lookTie.do"
 */
public class ModifyRevertInfoAction extends Action {
	/*
	 * Generated Methods
	 */
	private RevertInfoDao revertInfoDao;
	private Revertinfo revertinfo;
	/**
	 * @return the revertinfo
	 */
	public Revertinfo getRevertinfo() {
		return revertinfo;
	}

	/**
	 * @param revertinfo the revertinfo to set
	 */
	public void setRevertinfo(Revertinfo revertinfo) {
		this.revertinfo = revertinfo;
	}

	/**
	 * @return the revertInfoDao
	 */
	public RevertInfoDao getRevertInfoDao() {
		return revertInfoDao;
	}

	/**
	 * @param revertInfoDao the revertInfoDao to set
	 */
	public void setRevertInfoDao(RevertInfoDao revertInfoDao) {
		this.revertInfoDao = revertInfoDao;
	}

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		RevertInfoForm revertInfoForm = (RevertInfoForm) form;// TODO Auto-generated method stub
		
		int id = revertInfoForm.getId();
		List list = (List)revertInfoDao.findById(id);
		Revertinfo revertinfo = (Revertinfo)list.get(0);
		String revertcontent = revertInfoForm.getRevertcontent();
		String revertface = revertInfoForm.getRevertface();
		FormFile picture = revertInfoForm.getPicture();

		revertinfo.setRevertcontent(revertcontent);
		if(revertface!=null){
			revertinfo.setRevertface(revertface);
		}
		if(picture.getFileName()!=null&&!picture.getFileName().equals("")){
			revertinfo.setPicture(picture.getFileName());
			try {
				InputStream stream = picture.getInputStream();// 把文件读入
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				OutputStream bos = new FileOutputStream("d:/oafile/bbs/"
						+ picture.getFileName());// 建立一个上传文件的输出流
				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);
			}
		}
		
		revertInfoDao.updateRevertInfo(revertinfo);
		return mapping.findForward("success");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -