当前位置: 代码迷 >> Java Web开发 >> 请问:Jetty解析html的有关问题
  详细解决方案

请问:Jetty解析html的有关问题

热度:687   发布时间:2016-04-17 14:13:24.0
请教:Jetty解析html的问题
我在Tomcat下运行的很好的程序,显示的文件夹下的文件列表也是正确的。但是相同的页面部署到jetty下面后,出现了问题:显示列表发生错误,有的显示了两次,而且布局也乱了。当我把 <img> 标签去掉的时候,列表显示行数又是正确的。可是我现在必须用 <img> 标签,为的是把当前目录下是图片的文件显示出来。请问这是什么原因造成的,有什么好的解决方法,谢谢了。

代码片段如下:

<%
    request.setCharacterEncoding( "gb2312 ");  

    String   strDir   =   request.getParameter( "path ");  
    if(strDir==null||strDir.length() <1)
    {
          strDir   =   "D:\\mywork\\tree\\Web\\tree ";             //文件存放默认路径
    }
    StringBuffer   sb=new   StringBuffer( " ");
    StringBuffer   sbFile=new   StringBuffer( " ");
 
    try   {
       
        out.print( " <div   align= 'center '> ");
        out.println( " <table   border=1   width= '100% '   bgcolor= '#F1f1f1 '> <tr> <td   width= '30% '> 当前目录:   <b> "   +strDir+   " </b> </td> </tr> </table> <br> ");
        File   objFile   =   new   File(strDir);
        File   list[]   =   objFile.listFiles();  
        if(objFile.getAbsolutePath().length()> 3)   {
        %>
        <a   href= "?path= <%=objFile.getParentFile().getAbsolutePath()%> "> 上一级目录 </a> <p>
        <%
        }
        %>
        <table   width= "50% "   border=1>
        <%
        System.out.println(list.length);
        for(int   i=0;i <list.length;i++   )   {
            if(list[i].isDirectory())   {
            %>
            &nbsp;&nbsp; <a   href= "?path= <%=list[i].getAbsolutePath()%> "> <%=   list[i].getName()%> </a> <br>
            <%
            }   else   {
           
        %>
        <tr>
            <TD> <IMG   alt= " "   height= "100 "     src= " <%=list[i].getPath()%> "   width= "100 "   border=0> </IMG> </TD>
            <td> <%=list[i].getName()   %> </td>
        </tr>
        <%
            }  
        }

        %>
        </table>
        <%

    }   catch(Exception   e)   {
        //out.println( " <font   color=red> "+   e.toString()+   " </font> ");
    }
  相关解决方案