jsp页面的问题: getWebiReports(infoStore)是一个字符串,中间有“\t”类型的空格,以这个空格为分界点把这个字符串分成i个,
如何做,下面的程序在“document.write("<%= title[i]%>") ”提示错误,和其中的i有关,如何获得这个i<body> 
      
      <div id="rotate">
            <ul>        
         <% out.println(getWebiReports(infoStore)); %>
         <% out.println(getWebiReports(infoStore).split("\t").length); %>
         <% String[] title=getWebiReports(infoStore).split("\t");%>
        
     
           <script type="text/javascript">    
            for (i = 0; i < <% out.println(getWebiReports(infoStore).split("\t").length); %>; i++)
            {                
                document.write("<li>")   
                document.write("<a href=http://localhost:8080/report/report3.jsp target=open>")   
                document.write("<span>")  
                document.write("<%= title[i]%>")    ///////报错行///////
                document.write("</span></a></li>") 
                }          
           </script> 
                </ul>
            
           
        </div>
    </body>

解决方案 »

  1.   

    String s="2 34 43 ";
    String[] str = strstr.split(" ");
    str.length;
      

  2.   

    to:zhangpeixv没有看懂我说的什么
      

  3.   

    你的i是JS里的i,不是服务器代码的i
      

  4.   

    1.不用再用javascript的document.write写页面了。直接通过for循环在JSP直接写就Ok了。
    2.代码大致如下:<body> 
          
          <div id="rotate"> 
                <ul>        
            <% out.println(getWebiReports(infoStore)); %> 
            <% out.println(getWebiReports(infoStore).split("\t").length); %> 
            <% String[] title=getWebiReports(infoStore).split("\t");%> 
            <%
                for (i = 0; i<title.length; i++) 
                {    
            %>            
                    <li>
                    <a href=http://localhost:8080/report/report3.jsp target=open>")
                    <span> 
                     <%= title[i]%>
                    </span> </a> </li>
             <%}%>       
                    </ul> 
                
              
            </div> 
        </body>