首页>代码>S2SH(spring+struts2+hibernate)整合开发java web开源个人博客系统源码>/Blog/src/com/blog/action/article/manage/ArticleDeleteAction.java
package com.blog.action.article.manage;

import java.io.File;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.blog.BaseAction;
import com.blog.entity.Article;
import com.blog.service.ArticleService;

@Controller
public class ArticleDeleteAction extends BaseAction{
	@Resource ArticleService articleServiceImpl;
	
	private Integer id;
	private String imagePath;
	private Article article;
	private String realPath;
	
	public String execute(){
		article = articleServiceImpl.query(id);
		if(article.getImage()==null||"".equals(article.getImage().trim())){
			articleServiceImpl.delete(id);
			return "success";
		}
		imagePath = article.getImage();
		imagePath = imagePath.substring(3, imagePath.length());
		realPath = servletContext.getRealPath(imagePath);
		File file = new File(realPath);
		if(file.exists()){
			System.out.println("删除了文件"+realPath);
			file.delete();
		}
		articleServiceImpl.delete(id);
		return "success";
		
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
}
最近下载更多
wanglinddad  LV54 2022年5月10日
云生123456  LV6 2022年3月24日
dcdc12  LV6 2021年12月21日
lekers  LV14 2021年12月16日
lsglsg9  LV22 2021年9月8日
ceelf48  LV6 2021年7月13日
shishizhouzhou  LV12 2021年6月15日
XcHyxa  LV7 2021年6月9日
15525425383  LV6 2021年5月23日
1207748096  LV6 2021年5月12日
最近浏览更多
空中飞尘  LV13 2023年12月13日
abandan  LV4 2023年11月6日
和鱼崽  LV6 2023年10月2日
tangyongheng08  LV6 2023年7月21日
三十一  LV2 2023年6月28日
li951753  LV2 2023年6月19日
微信网友_6477647054655488  LV2 2023年6月1日
13133117021  LV4 2023年5月31日
mishidelu 2023年5月26日
暂无贡献等级
899558  LV1 2023年4月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友