Jsp中导入CSS样式没效果,以扩展名.html打开有相关,除了直接写在JSp上才会有效果
<%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%><%Stringpath=request.ge...
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.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="styles.css">
-->
<style type="text/css">
<!--
@import url("../CSS/layout.jsp");
-->
</style>
</head>
<body>
<div id="container">
<div id="header">This is the Header</div>
<div id="menu">This is the Menu</div>
<div id="mainContent">
<div id="custom">This is the Custom</div>
<div id="sidebar">This is the sidebar</div>
<div id="content">2列左侧固定右侧自适应宽度+头部+导航+尾部</div>
</div>
<div id="footer">This is the footer</div>
</div>
</body>
</html> 展开
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.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="styles.css">
-->
<style type="text/css">
<!--
@import url("../CSS/layout.jsp");
-->
</style>
</head>
<body>
<div id="container">
<div id="header">This is the Header</div>
<div id="menu">This is the Menu</div>
<div id="mainContent">
<div id="custom">This is the Custom</div>
<div id="sidebar">This is the sidebar</div>
<div id="content">2列左侧固定右侧自适应宽度+头部+导航+尾部</div>
</div>
<div id="footer">This is the footer</div>
</div>
</body>
</html> 展开
4个回答
展开全部
这不是新建JSP的时候都给了标准写法么?
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
这样写不就好了么
<link rel="stylesheet" type="text/css" href="path/styles.css">
注意path是与引入css的jsp文件相对路径,路径对了就错不了
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
这样写不就好了么
<link rel="stylesheet" type="text/css" href="path/styles.css">
注意path是与引入css的jsp文件相对路径,路径对了就错不了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你仔细看一下啊是不是CSS文件导入地址的问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把<base href="" />标签代码去了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
去了也不行呀
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询