日期:2014-05-18  浏览次数:20722 次

为什么score的值不是2,而是0?
<%@page   contentType= "text/html;charset=GBK "   %>
<html>
<body   bgcolor= "pink ">
<font   size=5>
<form   action= "answer.jsp ">
<table   >
<tr>
<td>
  which   Company   does   Bill   found?
</td>
</tr>
<tr>
<td>
<input   type= "radio "   name= "r "   value= "a "> Sun
</td>
<td>
<input   type= "radio "   name= "r "   value= "b "> Microsoft
</td>
<td>
<input   type= "radio "   name= "r "   value= "c "> Sony
</td>
<td>
<input   type= "radio "   name= "r "   value= "d "> Lenovo
</td>
</tr>
</table>
<table   >
<tr>
<td>
What 's   number   of     bill 's   wealth?
</td>
</tr>
<tr>
<td>
<input   type= "radio "   name= "s "   value= "a "> 5000
</td>
<td>
    <input   type= "radio "   name= "s "   value= "b "> 500
</td>
<td>
<input   type= "radio "   name= "s "   value= "c "> 50
</td>
<td>
<input   type= "radio "   name= "s "   value= "d "> 5
</td>
</tr>
<tr>
<td>
<input   type= "submit "   name= "submit "   value= "OK ">
</td>
</tr>
</table>
</form>
</font>
</body>
</html>
下面的是answer.jsp:
<%@page   contentType= "text/html;charset=GBK "   %>
<html>
<body   bgcolor= "cyan ">
<font   size=5>
<%  
int   score=0;
String   strFirst=request.getParameter( "r ");
String   strSecond=request.getParameter( "s ");
if(strFirst==null)
{
      strFirst= " ";
}
if(strSecond==null)
{
      strSecond= " ";
}
if(strSecond== "b ")
{
    score++;
}
if(strFirst== "b ")
{
    score++;
}
out.print( "you   score   is:   "+score);
%>
</font>
</body>
</html>


------解决方案--------------------
确实,你首先要描述一下,谁有那么多时间给你啊!想帮你都不行
------解决方案--------------------
呵呵,我耐着性子看完了。

这是因为字符串的比较不能使用==操作符。
if (strFirst.equals( "a ")) score++;
if (strSecond.equals(