0

我有 .jsp 页面:index.jsp,它具有带链接的形式:

<form name="firstForm" method="get" action="list.form">
 //-//-//

         <a href = "removeFromStorage?id=<%=index %>">Remove from storage</a>
 //-//-//

</form> 

我有我的控制器:

@Controller

@RequestMapping(value = "/removeFromStorage")

public class MyController {

@RequestMapping(value = "/removeFromStorage", method = RequestMethod.GET)
public String test(@RequestParam("name") String name, ModelMap model){

    //must get index of order, that must delete
    //int index_remove = new Integer(req.getParameter("index"));


    return "index";//request.getRequestDispatcher("hello.jsp").forward(req,res);
}

}

如何将控制器 (MyController) 映射到 url (removeFromStorage)?

我在 MyController 的注释中写了什么来处理 .jsp-page 中的 url=removeFromStorage?

4

1 回答 1

0

您拥有的控制器映射

@RequestMapping(value = "/removeFromStorage", method = RequestMethod.GET)value = "/removeFromStorage"

/removeFromStorage声明对与应用程序上下文相关的路径的 GET http 请求的处理。要使您的锚点<a href>removeFromStorage对于上下文路径,您可以将其更改为:

<a href = "${pageContext.request.contextPath}/removeFromStorage?id=<%=index %>">Remove from storage</a>
于 2013-04-29T16:25:25.410 回答