【发布时间】:2014-04-16 21:39:41
【问题描述】:
我已经尝试了两个小时,但仍然没有得到结果。我在“test.jsp”文件中有一些像这样的html
<input type ="submit" name="watch" value="Edit" id="edit"></input>
<input type ="submit" name="case" value="Edit" id="editt"></input>
然后我有一个表单,当按下上面的任一按钮时,会使用 jquery 弹出
<form action="servlet.jsp" method="post">
<fieldset>
<label for="Name">Name</label>
<input type="text" name="name" id="name" value=""><br>
<label for="Price">Price</label>
<input type="text" name="Price" id="price" value=""><br>
</fieldset>
</form>
我的 JSP 包括
<% String param = request.getParameter("watch"); %>
<% String param2 = request.getParameter("case"); %>
所以基本上我有两个编辑按钮,取决于按下哪个编辑按钮,它应该预先填充表单值。现在我的表单值为“”,因为无论我按下什么按钮,我的getParameter 总是显示为空。
我已经尝试了以下代码来检查值是否为 NULL,如果它们不是,则执行某些操作等,但无论按钮如何,都返回 null
if(param !=null){
//assign variables and populate with data x
}
//and so on
所以我的问题是,首先,我是否正确“获取”了参数。其次,如果是这样,任何想法为什么无论我按下哪个提交按钮,我都将这两个参数都设为 null。
【问题讨论】: