本人以前也使用过MzTree,并且很好用。但是最近遇到一个非常奇怪的问题,望各位大侠帮忙解决。
问题是这个样子的。
第一种方法,通过html的方式引入jsframework.js。
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<link href="${pageContext.request.contextPath}/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jsframework.js" charset="utf-8"></script>
</head>
然后访问,http://localhost:8080/MyApp/js/mztree/nav.jsp,则可以正常显示出menu tree。奇怪的问题在于第二种。
因为我们都知道,在jsp程序中,是不能按照上面绝对路径引入js的,所以改成。
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<link href="${pageContext.request.contextPath}/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/mztree/jsframework.js" charset="utf-8" ></script>
</head>
在访问,http://localhost:8080/MyApp/js/mztree/nav.jsp问题出现了,先是。
System.Global File not found
System.Web.UI.WebControls.MzTreeView file not found
然后说MzTreeView未定义。代码都是一样的代码,只是引入js的方式不同,并且我调试过,js的确引入成功。
但是为什么不好用呢?网牛人,帮忙,谢谢!

解决方案 »

  1.   

    补充一下,所有工程文件都是UTF-8编码格式
      

  2.   

    把你的webapp名称改为小写就没事了……你试试
    http://localhost:8080/myapp/js/mztree/nav.jsp
      

  3.   

    刚才看了下梅花的源码,彻底解决了下这个问题,无论webapp的名称大写还是小写都不会再有这个问题了。LZ可以试试。
    修改jsframework.js。
    System._mapPath = function(namespace, path)
    {
      if("string"==typeof path && path.length>3)return path.toLowerCase();
      var p=(System.path+"/"+namespace.replace(/\./g,"/")+".js").toLowerCase();
      return p +(("undefined"==typeof path||path) ? "" : "?t="+ Math.random());
    };
    改为:
    System._mapPath = function(namespace, path)
    {
      if("string"==typeof path && path.length>3)return path.toLowerCase();
      var p=System.path+"/"+(namespace.replace(/\./g,"/")+".js").toLowerCase();
      return p +(("undefined"==typeof path||path) ? "" : "?t="+ Math.random());
    };