首页>代码>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;
	}
	
}
最近下载更多
15828038591  LV11 2025年12月17日
wanglinddad  LV55 2022年5月10日
云生123456  LV6 2022年3月24日
dcdc12  LV6 2021年12月21日
lekers  LV14 2021年12月16日
lsglsg9  LV23 2021年9月8日
ceelf48  LV6 2021年7月13日
shishizhouzhou  LV12 2021年6月15日
XcHyxa  LV7 2021年6月9日
15525425383  LV6 2021年5月23日
最近浏览更多
Osit888  LV12 昨天
15828038591  LV11 2025年12月17日
t_heyao 2025年11月18日
暂无贡献等级
1140717565  LV2 2025年7月18日
nightstarshii 2025年1月26日
暂无贡献等级
krispeng  LV15 2024年11月20日
WBelong  LV8 2024年9月20日
微信网友_6906962132258816  LV7 2024年5月15日
空中飞尘  LV13 2023年12月13日
abandan  LV4 2023年11月6日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友