在 <input> JSP 中将参数传递给标记



我正在尝试将一个参数传递给JSP中HTML表单的输入标记。我有一个显示患者记录的表格,其中有一个"编辑"按钮,可重定向到update.jsp页面,在该页面上显示更新表单,所有初始值都设置为原始表格中的值。Patient.jsp文件中最重要的表如下所示:

<c:forEach var="patients" items="${patients}">
<tr>
<td>${patients.getPatientId()}</td>
<td>${patients.getPatientfName()}</td>
<td>${patients.getPatientlName()}</td>
<td>${patients.getPatientEmail()}</td>
<td>${patients.getPatientPhone()}</td>
<td class="text-center">
<a href='update.jsp?u=${patients.getPatientId()}' class="btn">Edit</a>
</td>
</tr>
</c:forEach>

在update.jsp文件中,我有一个简单的表单(为了简单起见,只显示了一行(:

<form name="update" action="ProductDisplay" method="post">
<table>
<tr>
<td>Patient ID:</td>
<td><input type="text" name="ID" value="${request.getParameter("u")}"></td>
</tr>
</table>
</form>

正在尝试将文本字段的值设置为等于原始表中的值。如果我直接在update.jsp中访问它,就像这样:

<%
String str = request.getParameter("u");
System.out.println(str);
%>

一切正常,表中ID的值被传递并打印出来。然而,当我尝试以以下形式使用它时(value="${request.getParameter("u"(}&"(什么都不发生,字段值保持为空。任何帮助都将不胜感激。提前谢谢!

我想明白了。对于那些可能遇到相同问题的人,请使用:

<%
String str = request.getParameter("u");
%>

然后在标签中:

value='<%=str%>'

最新更新