buyerAction 中,有一个searchName()方法,返回 boolean 类型。在 register.jsp 页面中:
<script type="text/javascript">
        function checkName(){
//请求 的 是 Struts2 的 action.
              $.post("buyer/buyerAction_searchName",{username : $("#vipName").val()},callback);
        }
        function callback(isRoot){
               if(isRoot){
                alert(isRoot);
            }
</script>结果 打印出来的 是 报错信息: 大体意思是  不能 把 boolean 转换为 String.
如何 处理?

解决方案 »

  1.   

    是不是isRoot比方是true,然后就不能alert(true)?   在这里不能 把 boolean 转换为 String??其他地方我觉得没有什么可疑啊?要不不要用alert方式来验证那个值了,直接用inner方式打印到页面上某个地方看下值好了,要不就alert("123")  什么的,同样也能证明isRoot是Boolean的true或者false型.
      

  2.   

    但是 不论 isRoot 是什么值,或者说 请求的方法返回的是什么值  
    if(isRoot){
      alert(isRoot);
      }else{
         alert("aaaa")

    它 只执行 isRoot 为true 不执行
    else 里的东西。
    有点伤脑筋啊。