0
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")
public class DeleteController {
@Autowired
private ArticleService articleService;
@RequestMapping(value="/delete")
public String deleteService(@RequestParam("ID") final Integer ids) {
System.out.println("hello");
articleService.deleteService(ids);
return "redirect:/articles";
}
}
可以在这里~~~~~~~~~~~~~~~~~~~~~~,如何删除链接(HREF)
<td><a href="/articles/delete.do?ID=${article.articleId}">delete</a></td>
这个问题只是贴了我lot.I认为这可能是href.Controller的问题不能把握的HREF
的链接(第二次尝试),但似乎还没有这样的
import net.roseindia.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("/articles")
public class DeleteController {
@Autowired
private ArticleService articleService;
@RequestMapping(value="/delete/{ID}")
public String deleteService(@PathVariable("ID") final Integer ids) {
System.out.println("hello");
articleService.deleteService(ids);
return "redirect:/articles";
}
}
td><a href="/articles/delete/${article.articleId}.html">delete</a></td>
这方面的工作是我的web.x毫升
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Promble是
HTTP状态404 - /articles/delete/2.html
类型状态报告
消息/articles/delete/2.html
description请求的资源不可用。
你的问题是? – BevynQ
delete -----这不适合被控制器 – Yuxin
所掌握,它看起来没问题,你会得到一个异常吗? – BevynQ