日期:2014-05-18  浏览次数:20729 次

为什么会不能显示背景啊?是不是JSP中不可能有背景啊?代码如下:
h1,   h2,   h3,   h4,   h5,   h6   {
    margin:   1em   1em   1em   1em;
    padding:1em   1em   1em   1em;
    color:#ff00ff;
    border:   thin   dotted   green;  
    text-align:center;
}
body   {
    text-align:center;
    font:   normal   small-caps   600   12pts/150%   Courier;  
    color:   green;  
    background:   url( "../image/backdround.jpg ");
}

a   {
    color:red;
}


<%@   page   contentType= "text/html;charset=gb2312 "%>

<html>
<head>
<title> JSP测试 </title>
                                <style   type= "text/css ">
<!--
@import   url(css/styles.css);
-->
</style>
</head>
<body>
<h3> 测试首页 </h3>
<a   href   = "Date.jsp "> 时间测试 </a>
</body>
</html>

------解决方案--------------------
没显示背景图片一般有两原因,一是背景图片的相对路径不对,二是有背景颜色!
还有啊!你这个直接放到jsp里还是用css样式文件引用啊?一定要注意相对路径哦!
------解决方案--------------------
<%@ page contentType= "text/html;charset=gb2312 "%>

这个应该放在开头
------解决方案--------------------
<body style= "background:fixed url( ' <%=request.getContextPath()%> /images/page/tu2.gif ') center center no-repeat " >
一个加载 图片的例子,(要根据你的目录把图片加上即可);
多数还是目录不正确的问题