?? deletefileaction.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;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -