日期:2014-05-18 浏览次数:20740 次
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>All Articles</title>
</head>
<body>
<h1>List Articles</h1>
<a href="articles/add.html">Add Article</a>
<c:if test="${!empty articles}">
<table>
<tr>
<th>Article ID</th>
<th>Article Name</th>
<th>Article Desc</th>
<th>Added Date</th>
</tr>
<c:forEach items="${articles}" var="article">
<tr>
<td><c:out value="${article.articleId}"/></td>
<td><c:out value="${article.articleName}"/></td>
<td><c:out value="${article.articleDesc}"/></td>
<td><c:out value="${article.addedDate}"/></td>
<td><a href=articles.do?actionMethod=delete&ID=${article.articleId}>delete</a></td>
//应该是这里写的有问题
</tr>
</c:forEach>
</table>
</c:if>
</body>
</html>
package net.roseindia.controller;
import net.roseindia.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("/articles.do")
public class DeleteController {
@Autowired
private ArticleService articleService;
/**
* @RequestMapping(params = "actionMethod=delete", method = RequestMethod.POST)
public String delete(@RequestParam("id") final Long[] ids) {
List<GoodsBrand> brands = brandService.findDatasByIds(GoodsBrand.class,
ids);
if (brands != null && brands.size() > 0) {
brandService.deleteAll(brands);
}
return REDIRECTQUERYPATH;
}
* @return
*/
@RequestMapping(params = "actionMethod=delete")
public String deleteService(@RequestParam("ID") final Integer ids) {
System.out.println("hello");
articleService.deleteService(ids);
return "redirect:/articles";
}
}