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

📄 deletefileaction.java

📁 不说了
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.david.struts.action;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.david.bo.File;
import com.david.service.IFileService;
import com.david.util.IParseRequest;

/** 
 * MyEclipse Struts
 * Creation date: 10-21-2007
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 */
public class DeleteFileAction extends FilterRequestAction {
	/*
	 * Generated Methods
	 */
	private IFileService fileService;
	
	private IParseRequest parseRequest;
	
	public void setParseRequest(IParseRequest parseRequest) {
		this.parseRequest = parseRequest;
	}
	public void setFileService(IFileService fileService) {
		this.fileService = fileService;
	}
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws IOException 
	 */
	public ActionForward doExecute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		// TODO Auto-generated method stub
		//int fileId=Integer.parseInt(request.getParameter("deleteId"));
		//IFileService fileService=(IFileService)this.getBean("fileService");
		int deleteId=parseRequest.parseInt(request, "deleteId", 0);
		File file=new File();
		file.setId(deleteId);
		file.setFileUrl(fileService.getFileById(deleteId).getFileUrl());
		int categoryId=fileService.getFileById(deleteId).getCategory().getId();
		if(fileService.deleteFileById(file)){
			//response.getWriter().println("Deleted!");			
			request.setAttribute("categoryId", categoryId);
			return mapping.findForward("goto");
			//return null;
		}else{
			response.getWriter().print("Error!<br/>Please try it again!");
			//response.getWriter().println("false");
			//return mapping.findForward("goto");
			return null;
		}
	}
}

⌨️ 快捷键说明

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