⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index_0002ejsp_jsp.java

📁 一个目录树
💻 JAVA
字号:
import java.util.*;
import java.io.FileFilter;
import java.io.File;
import com.kewf.dirtree.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;


public class index_0002ejsp_jsp extends HttpJspBase {


    static {
    }
    public index_0002ejsp_jsp( ) {
    }

    private static boolean _jspx_inited = false;

    public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
    }

    public void _jspService(HttpServletRequest request, HttpServletResponse  response)
        throws java.io.IOException, ServletException {

        JspFactory _jspxFactory = null;
        PageContext pageContext = null;
        HttpSession session = null;
        ServletContext application = null;
        ServletConfig config = null;
        JspWriter out = null;
        Object page = this;
        String  _value = null;
        try {

            if (_jspx_inited == false) {
                synchronized (this) {
                    if (_jspx_inited == false) {
                        _jspx_init();
                        _jspx_inited = true;
                    }
                }
            }
            _jspxFactory = JspFactory.getDefaultFactory();
            response.setContentType("text/html; charset=GBK");
            pageContext = _jspxFactory.getPageContext(this, request, response,
            			"", true, 8192, true);

            application = pageContext.getServletContext();
            config = pageContext.getServletConfig();
            session = pageContext.getSession();
            out = pageContext.getOut();

            // HTML // begin [file="/index.jsp";from=(0,48);to=(1,0)]
                out.write("\r\n");

            // end
            // HTML // begin [file="/index.jsp";from=(1,47);to=(2,0)]
                out.write("\r\n");

            // end
            // HTML // begin [file="/index.jsp";from=(2,38);to=(3,0)]
                out.write("\r\n");

            // end
            // HTML // begin [file="/index.jsp";from=(3,32);to=(4,0)]
                out.write("\r\n");

            // end
            // HTML // begin [file="/index.jsp";from=(4,38);to=(6,0)]
                out.write("\r\n\r\n");

            // end
            // begin [file="/index.jsp";from=(6,2);to=(92,0)]
                
                static Hashtable images=new Hashtable();
                static Hashtable actions=new Hashtable();
                static String script;
                static {
                    images.put("IMAGE_PLUS", "images/plus.gif");
                    images.put("IMAGE_PLUS_LAST", "images/pluslast.gif");
                    images.put("IMAGE_MINUS", "images/minus.gif");
                    images.put("IMAGE_MINUS_LAST", "images/minuslast.gif");
                    images.put("IMAGE_MIDBLK", "images/midblk.gif");
                    images.put("IMAGE_BLANK", "images/blank.gif");
                    images.put("IMAGE_LASTBLK", "images/lastblk.gif");
                    images.put("IMAGE_LINE", "images/line.gif");
                    images.put("IMAGE_FOLDER", "images/folder.gif");
                    images.put("IMAGES_FOLDER_OPEN","images/folderopen.gif");
                    StringBuffer sc=new StringBuffer("<script type=\"text/javascript\">\r\n");
                    Iterator imgs=images.values().iterator();
                    int k=0;
                    while(imgs.hasNext()){
                      sc.append("var image"+k+"=new Image();\r\n");
                      sc.append("image"+k+".src=\""+(String)imgs.next()+"\";\r\n");
                      k++;
                    }
                    sc.append("</script>\r\n");
                    script=sc.toString();
                    actions.put("CLICK_FOLDER","clickFolder");
                    actions.put("CLICK_DOCUMENT","clickDocument");
                    actions.put("CLICK_FOLDER_IMG","openFolder");
                    actions.put("MOUSEOVER","overMouse");
                    actions.put("MOUSEOUT","outMouse");
                }
                
                  void paintChilds(Iterator childs,Writer w) throws IOException{
                    while(childs.hasNext()){
                      paintNode((Node)childs.next(),w);
                    }
                  }
                
                  void paintNode(Node n,Writer w) throws IOException{
                    w.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>");
                    int level=n.getLevel();
                    int id=n.getId();
                    Node parent=null;
                    String name=((File)n.getValue()).getName();
                    boolean last=false;
                    for(int i=level-1;i>0;i--){
                      parent=n.getParent(i);
                      last=parent.isLast();
                      w.write("<td><img src=\"" +
                              (String) images.get(last ? "IMAGE_BLANK":"IMAGE_LINE" ) +
                              "\" border=\"0\"></td>");
                    }
                    last=n.isLast();
                    if(n.hasChilds()){
                      w.write("<td id=\"plus" + id + "\" style=\"cursor:hand\" onClick=\""+
                		((String)actions.get("CLICK_FOLDER_IMG")+"(document,"+id+")")+"\"><img src=\""
                +
                                (String) images.get(last ? "IMAGE_PLUS_LAST" : "IMAGE_PLUS") +
                                "\" border=\"0\"></td>");
                    }
                    else {
                      w.write("<td id=\"plus" + id + "\"><img src=\"" +
                              (String) images.get(last ? "IMAGE_MINUS_LAST" : "IMAGE_MINUS") +
                              "\" border=\"0\"></td>");
                    }
                    w.write("<td id=\"f" + id + "\"><img src=\"" +
                            (String) images.get("IMAGE_FOLDER") + "\" border=\"0\"></td>");
                    if(n.hasChilds()){
                      w.write("<td id=\"td" + id + "\" style=\"cursor:hand\" onClick=\""+
                	(String)actions.get("CLICK_FOLDER")+"(document,"+id+"),"+
                	(String)actions.get("CLICK_FOLDER_IMG")+"(document,"+id+")"+"\">" +
                	name + "</td>");
                    }
                    else{
                      w.write("<td id=\"td" + id + "\" style=\"cursor:hand\" onClick=\""+
                	(String)actions.get("CLICK_FOLDER")+"(document,"+id+")"+"\">" +
                	  name + "</td>");
                    }
                    w.write("</tr></table>");
                    if (n.hasChilds()) {
                      w.write("<div id=\"div" + id + "\" style=\"display:none\">");
                      paintChilds(n.getChilds(), w);
                      w.write("</div>");
                    }
                    w.flush();
                  }
            // end
            // HTML // begin [file="/index.jsp";from=(92,2);to=(107,0)]
                out.write("\r\n\r\n<html>\r\n<head>\r\n<title>\r\ntree\r\n</title>\r\n<style type=\"text/css\">\r\ntd{font:13px/16px;}\r\nA:link {text-decoration: none;font-size: 12px; color: #0000ff}\r\nA:visited {text-decoration: none;font-size: 12px; color: #0000ff}\r\nA:active {text-decoration: none;font-size: 12px}\r\nA:hover {text-decoration: underline;font-size: 12px}\r\nimg{vertical-align: bottom;}\r\n</style>\r\n");

            // end
            // begin [file="/index.jsp";from=(107,3);to=(107,9)]
                out.print(script);
            // end
            // HTML // begin [file="/index.jsp";from=(107,11);to=(154,0)]
                out.write("\r\n<script type=\"text/javascript\">\r\nfunction changeColor(doc,k){\r\n  var old=doc.thisForm.selectedNode.value;\r\n  if(old!=k){\r\n    if(old!=\"\"){\r\n      doc.all(\"td\"+old).style.backgroundColor=doc.thisForm.bgColor.value;\r\n    }\r\n    doc.all(\"td\"+k).style.backgroundColor=doc.thisForm.selectedColor.value;\r\n    doc.thisForm.selectedNode.value=k;\r\n  }\r\n}\r\nfunction clickDocument(doc,k){\r\n  changeColor(doc,k);\r\n  alert(\"Click document \"+doc.all(\"td\"+k).innerText+\".\");\r\n}\r\nfunction openFolder(doc,k){\r\n  var o=doc.all(\"div\"+k);\r\n  if(o.style.display==\"none\"){\r\n    o.style.display=\"block\";\r\n  }\r\n  else{\r\n    o.style.display=\"none\";\r\n  }\r\n  replaceImg(doc,k);\r\n  var k=0;\r\n  while((o=o.parentElement)!=doc&&o!=null){\r\n    k=o.id.indexOf(\"div\");\r\n    if(k!=-1){\r\n      if(o.style.display==\"none\"){\r\n        o.style.display=\"block\";\r\n\treplaceImg(doc,o.id.substring(k));\r\n      }\r\n    }\r\n  }\r\n}\r\nfunction clickFolder(doc,k){\r\n  changeColor(doc,k);\r\n  alert(\"Click folder \"+doc.all(\"td\"+k).innerText+\".\");\r\n}\r\nfunction replaceImg(doc,k){\r\n\r\n}\r\n</script>\r\n</head>\r\n\r\n<body>\r\n");

            // end
            // begin [file="/index.jsp";from=(154,2);to=(160,0)]
                
                out.flush();
                File f=new
                File(this.getServletConfig().getServletContext().getRealPath("/tree")).getParentFile();
                Tree t=Tree.getTree(f,new FileContainer());
                paintChilds(t.getChilds(),response.getWriter());
            // end
            // HTML // begin [file="/index.jsp";from=(160,2);to=(168,0)]
                out.write("\r\n<form name=\"thisForm\">\r\n  <input type=\"hidden\" name=\"selectedNode\">\r\n  <input type=\"hidden\" name=\"bgColor\" value=\"#FFFFFF\">\r\n  <input type=\"hidden\" name=\"selectedColor\" value=\"#9999FF\">\r\n</form>\r\n</body>\r\n</html>\r\n");

            // end

        } catch (Throwable t) {
            if (out != null && out.getBufferSize() != 0)
                out.clearBuffer();
            if (pageContext != null) pageContext.handlePageException(t);
        } finally {
            if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -