这是我在eclipse里一个jsp文件,引用了一个treeview的js代码
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="StyleSheet" href="style/dtree.css" type="text/css" />
<script type="text/javascript" src="js/dtree.js"></script>
<title>左边菜单</title>
</head>
<div class="dtree"> <p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p> <script type="text/javascript">
<!-- d = new dTree('d'); d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif'); document.write(d); //-->
</script>
</div>
</body>
</html>
dtree.js放在了d:\eclipse\workspace\MIS\js文件夹下了,我发现如果手动把文件复制到ROOT里可以运行,但是在eclipse里调试运行就不通过,不能显示那个树形菜单,发现tomcat报错信息为:The requested resource (/MIS/js/dtree.js) is not available.
我已经把dtree.js导入到eclipse的javascript支持路径里了

解决方案 »

  1.   

    d:\eclipse\workspace\MIS\js是什么路径
    你应该在项目目录下的webroot下建一个Js文件夹,放进去
      

  2.   


    我在articleManage.jsp里的JS引用:
     <script type="text/javascript" src="../../module/js/dtree.js"></script>   
    样式引用:
     <link rel="StyleSheet" href="../../style/common/dtree.css" type="text/css" />
      

  3.   

    你的js可以在head标签里加入这句话看看<script type="text/javascript" src="<%=request.getContextPath() %>/js/dtree.js"> </script>