我试图将一个参数从jsp页面传递给Spring控制器文件。 但是,我失败了又失败了。
当我只放置a,b,c等数据库的真实数据而不是" $ {deleteList [' user_id']}"时,我的代码效果很好。
我不知道。 如果我能得到你的回答,我会感到高兴。
<table border="0">
<c:forEach items="${deleteList}" var="deleteList">
<tr><td align="right">ID:</td><td>${deleteList.user_id}</td></tr>
</c:forEach>
</table> <form action="${pageContext.request.contextPath}/user/delete" method="get"> <input type="hidden" name="user_id" value="${deleteList['user_id']}" />
<input type="submit" name="confirm" value="Delete" />
@RequestMapping(value = "/delete", params="confirm", method = RequestMethod.GET)
public String deleteConfirm(Model model, HttpServletRequest req) {
String user_id=req.getParameter("user_id");
UmsDAO dao=sqlSession.getMapper(UmsDAO.class);
ArrayList<UVO> uvo = dao.deleteList(user_id);
model.addAttribute("deleteList", uvo);
return "user/deleteConfirm";
}
<c:forEach items="${deleteList}" var="deleteList">
<tr><td align="right">ID:</td><td>${deleteList.user_id}</td></tr>
</c:forEach>
答案 0 :(得分:0)
您没有在user_id中发送任何值..
<tr><td align="right">ID:</td><td>${deleteList.user_id}</td>
<td> from this try once.. you will get specific value what you want</td>
</tr>
每次使用锚标记并在partameter中发送值
,而不是使用表格答案 1 :(得分:0)
解决方案: 使用HttpSession
例如:
@RequestMapping(value =“/ delete”,params =“confirm”,method = RequestMethod.GET) public String deleteConfirm(Model model,HttpServletRequest req){
HttpSession session = req.getSession();
String user_id = (String) session.getAttribute("user_id");
UmsDAO dao = sqlSession.getMapper(UmsDAO.class);
ArrayList<UVO> uvo = dao.deleteList(user_id);
model.addAttribute("deleteList", uvo);
return "user/deleteConfirm";
}