将值从一个jsp页面传递到另一个jsp页面 [英] Passing values from one jsp page to another jsp page
问题描述
我正在从数据库中检索值到jsp中的表(到列)
I'm retrieving values from database to table in jsp.(to a column)
我想将该值插入数据库的另一个表中.为此,我正在使用另一个jsp表将该值插入db,然后在我以前的jsp页面表单操作选项卡中调用该jsp页面.
I want to insert that value into another table in database. To do that I'm using another jsp table to insert that value in db and I call that jsp page in my previous jsp's page form action tab.
我使用request.getParameter()
方法将第一个jsp页面中的值获取到新的jsp页面,但是我无法使用request.getParameter()
获取值.
I use request.getParameter()
method to get the values in my first jsp page to new jsp page, but I couldn't get the values using request.getParameter()
.
我该如何解决?
推荐答案
打开第二个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 <%= .. %>
)
这篇关于将值从一个jsp页面传递到另一个jsp页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!