且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将值从一个jsp页面传递到另一个jsp页面

更新时间:2022-05-09 22:21:46

打开第二个JSP时,您必须将相关参数(我认为是ID)作为GET参数传递给第二页.也就是说,表格中的链接应如下所示:

When opening the 2nd JSP you have to pass the relevant parameters (an ID I suppose) as GET parameters to the second page. That is, the link in your table should look like:

<a href="edit.jsp?itemId=${item.id}" />

然后,您可以在第二页上使用request.getParameter("itemId")读取该参数.

Then you can read that parameter with request.getParameter("itemId") on the second page.

(如果不使用JSTL和EL,则将${..}替换为<%= .. %>)

(if not using JSTL and EL, the ${..} is replaced by <%= .. %>)