jsp页面加则使用easyui的tree就不会显示

风行傲天 2012-10-30 10:20:00
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'tree.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="../css/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../css/themes/default/icon.css">

<script type="text/javascript" src="<%=basePath%>/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/jquery.easyui.min.js"></script>

<script type="text/javascript" src="tree.js"></script>

</head>

<body>
<ul id="treess"></ul>
</body>
</html>

tree.js代码

//页面加载完后执行
$(document).ready(function(){
//调用树
initTree();
});

/**
* 初始化树
*/
function initTree(){

$("#treess").tree({

url: 'tree_data.json',
animate: true,
onClick: function(node){
$('#treess').tree('beginEdit', node.target);
}
});

}

如果把页面<base href="<%=basePath%>">这句话删掉,就可以显示树,不删要不报错要不就不显示,麻烦高手们指点,
和<base href="<%=basePath%>">有啥关系,小弟实在是不晓得,搞了半天才找到这个问题的
...全文
469 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
风行傲天 2013-01-14
  • 打赏
  • 举报
回复
虽然没有满意答案但还是谢谢大家帮忙
fengxing2 2013-01-14
  • 打赏
  • 举报
回复
可能是和easyui的js有冲突吧
风行傲天 2012-11-02
  • 打赏
  • 举报
回复
这个我知道,但现在是不明白<base href="<%=basePath%>">这个和easyui的js有什么关系,貌似好像是冲突还是什么的,不懂,只要有这句话,js文件就报错
风行傲天 2012-10-30
  • 打赏
  • 举报
回复
全换成相对路径也是这样的问题,
<html>
<head>
<title>My JSP 'tree.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="../css/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../css/themes/default/icon.css">

<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>

<script type="text/javascript" src="tree.js"></script>

</head>

<body>
<ul id="treess"></ul>
</body>
</html>

只要删除<base href="<%=basePath%>"> 这个就好了,页面也不引用它,但是只要在页面加<base href="<%=basePath%>">就是不显示
hch126163 2012-10-30
  • 打赏
  • 举报
回复
用相对于站点根目录的路径。

如果js 文件夹在站点根目录下:
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/js/jquery.easyui.min.js"></script>
猿敲月下码 2012-10-30
  • 打赏
  • 举报
回复
<base href=""> 就是指网页里面的相对链接的前缀url,如在<head></head>部分定义了此链接为http://www.sonyes.cn/,那么下面的<a href=aaa.html></a>代表http://www.sonyes.cn/aaa.html 这个标签的用处是解决编程时候的相对路径

参见

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧