如何通过window.open将值从一个jsp传递到另一个jsp
我从 one.jsp 获取 gra 值,如下所示
<script language="javascript">
function gotoAddPanelAction(elem)
{
var st=elem.value;
if(st!="")
{
Popup=window.open('SelectInterviewPannel2.jsp?gra='+st,'Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes',400,400);
}
else
{
validateForm(document.frm);
}
}
</script>
我正在检索 SelectInterviewPannel2.jsp 中的值,如下所示
<td width="60%" class="txt-lable">
<Select name="grade" ><option value="" selected>Select</option>
<%
String gra = request.getParameter("gra");
if(gra.value=="Level 1") {
%>
<option value="E1">E1</option><option value="E2">E2</option><option value="E3">E3</option><option value="E4">E4</option></select>
<% } else {%>
<option value="M1">M1</option><option value="M2">M2</option></select>
<% } %>
</td>
我的问题是在 SelectInterviewPannel2.jsp 中 if 语句未执行。我只得到用于选择的下拉框,其中没有任何值。
I am getting gra value from one.jsp as follows
<script language="javascript">
function gotoAddPanelAction(elem)
{
var st=elem.value;
if(st!="")
{
Popup=window.open('SelectInterviewPannel2.jsp?gra='+st,'Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes',400,400);
}
else
{
validateForm(document.frm);
}
}
</script>
I am retriving the value in SelectInterviewPannel2.jsp as follows
<td width="60%" class="txt-lable">
<Select name="grade" ><option value="" selected>Select</option>
<%
String gra = request.getParameter("gra");
if(gra.value=="Level 1") {
%>
<option value="E1">E1</option><option value="E2">E2</option><option value="E3">E3</option><option value="E4">E4</option></select>
<% } else {%>
<option value="M1">M1</option><option value="M2">M2</option></select>
<% } %>
</td>
My problem is in SelectInterviewPannel2.jsp if statement is not executing . I am getting only drop down box for select with no values in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
难道你不应该使用
equals()
方法进行字符串比较一些建议:
Shouldn't you use
equals()
method for string comparissionSome Suggestions:
首先,为什么这个标题:如何在java中删除整数中的逗号它与您的问题不匹配。
作为答案:
而不是
使用这个
In java
==
比较引用,而不是值并且要比较字符串的值,您应该使用.equals(str)
。First of all why this title: how to remove comma in integer in java it does not match with your question.
As an answer:
Instead of this
use this
In java
==
Compares references, not values and to compare values of string you should use.equals(str)
.如果 gra 参数不存在,
request.getParameter("gra")
将返回null
并使用if(gra.equals("Level 1")) 进行比较
会抛出空指针异常。所以可以尝试使用if("Level1".equals(gra))
来避免gra参数不存在时出现空指针异常If gra parameters does not exist ,
request.getParameter("gra")
will returnnull
and comparing usingif(gra.equals("Level 1"))
will throw out Null pointer exception . So you can try to useif("Level1".equals(gra))
to avoid the Null pointer exception when the gra parameters does not exist