Java springMVC,如何删除链接(href)

Java springMVC,如何删除链接(href),java,spring,jakarta-ee,spring-mvc,Java,Spring,Jakarta Ee,Spring Mvc,可能在这里~~~~~~~~~~~~~~~~~~~~~~ package net.roseindia.controller; import net.roseindia.service.ArticleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.w

可能在这里~~~~~~~~~~~~~~~~~~~~~~

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的问题。Controller无法抓住href的链接

(第二次尝试)但它似乎也不能像这样工作

<td><a href="/articles/delete.do?ID=${article.articleId}">delete</a></td>
import net.roseindia.service.ArticleService;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.stereotype.Controller;
导入org.springframework.web.bind.annotation.PathVariable;
导入org.springframework.web.bind.annotation.RequestMapping;
导入org.springframework.web.bind.annotation.RequestParam;
@控制器
@请求映射(“/articles”)
公共类删除控制器{
@自动连线
私人物品服务;
@请求映射(value=“/delete/{ID}”)
公共字符串deleteService(@PathVariable(“ID”)最终整数ID){
System.out.println(“你好”);
articleService.deleteService(ids);
返回“重定向:/articles”;
}
}
td>
这是我的web.xml

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> 

调度员
org.springframework.web.servlet.DispatcherServlet
1.
调度员
*.html
index.jsp
Promble是

HTTP Status 404-/articles/delete/2.html


类型状态报告

message/articles/delete/2.html


说明请求的资源不可用。

Http 404错误的原因是找不到Http请求的映射。从您的配置来看,似乎没有配置控制器和请求映射

您需要使用一些上下文配置定义调度程序,如下所示:

 <?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>

-----这不适用于被Controllerit抓住它看起来不错,你有例外吗?
<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<annotation-driven />
<context:component-scan base-package="net.roseindia.controller" />