<script type="text/javascript">
 function a(count)
 {
  (count).toString();
  alert(typeof(count));
  this.location.href = "editServlet?count"=count;
  this.forms[0].submit();
 }
</script>
<!--页面-->
<td width="100" class="hh" align="center" height="22">  
  <input type="text" name="count" size="5" value="<%=item.getCount()%>" onblur="a(<%=item.getCount()%>)"/>
</td>传递过来的count在java里是整形,alert(typeof(count))后,输出地是“number”类型,然后报错 : 不能给 '[string]' 赋值,也就是number转String没成功,请问应该怎么把整形给转成String呢?还是我别的地方写错了,大家帮我看看,谢谢了

解决方案 »

  1.   

    this.location.href = "editServlet?count"=count;
      

  2.   

    我猜你是想this.location.href = "editServlet?count="+count;
      

  3.   

      我这里确实马虎写错了 请问我的类型转换对吗? 还是number类型 number怎么转String呢?
      

  4.   

    就直接用+就可以 number会自动转换成string如果心里实在觉得不舒服就手动转一下"editServlet?count="+count.toString();
      

  5.   

    this.location.href = "editServlet?count="+count;就这一句行了,其他什么类型转换不要你去管
    count可以是数字,可以是字符,bool,null想是什么都没问题
      

  6.   

    这样写才对,this.location.href = "editServlet?count="+count;
      

  7.   

     
       ..........
    this.location.href = "editServlet?count="+count.ToString();
      

  8.   

    应该不用转换,因为http请求传输的数据全部都是字符串啊
      

  9.   

    this.location.href = "editServlet?count"+count;