您的位置:首页 > Web前端 > CSS

jsp无法引入外部.JS或者.CSS文件的有关问题 (转)

2013-10-31 16:26 771 查看
<!-- *************JSP代码******************-->
<%@ page language="java" pageEncoding="GBK" contentType="text/html;charset=gbk" isELIgnored="false"%>
<%
String path = request.getContextPath();
// 获得项目完全路径(假设你的项目叫MyApp,那么获得到的地址就是 http://localhost:8080/MyApp/):
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<!-- base需要放到head中 -->
<base href=" <%=basePath%>">
</head>
// 这里我们就可以直接使用相对路径(即: 相对于base标签)
<a href="jsp/login.jsp">Login </a>
</html>
<!-- *************************************-->

另参考:http://blog.sina.com.cn/s/blog_03c54d100100wo6n.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: