jsp页面加入头部以及底部,设置背景

来源:互联网 发布:出行软件英文怎么说 编辑:程序博客网 时间:2024/06/06 15:50

jsp页面加入头部以及底部,设置背景

注意事项:

头部和底部文件编码问题;

用include将头部文件以及底部文件包含进来<%@ includefile="xx.jsp"%>

设置背景图片时路径问题

 

头部文件:head.jsp

<%@ page language="java"contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<tablestyle="height:50px;width:100%;background-color:#cceeff;">

<trstyle="height:45px;">

 <tdstyle="align:center;">首页</td>

 <tdstyle="">招聘信息</td>

 <tdstyle="">公告</td>

 <tdstyle="">联系我们</td>

 <tdstyle="">企业产品</td>

</tr>

</table>

底部文件:down.jsp

<%@ page language="java"contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<div style="background-color:#ccddff;">

 联系我们:000000-5555555-55555</br>

xxxxxxxxxx-科技

</div>

将以上两个页面合并,同时设置背景图片

<%@ page language="java"contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

 <%String path = request.getContextPath();

String basePath =request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>   

<!DOCTYPEhtmlPUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<style>

body{

background-image:url(<%=basePath%>image/bg.jpg);

}

</style>

<body>

<%--加载页头和页尾--%>

<%@ include file="head.jsp"%>

<divstyle="height:500px;">内容</div>

<%@ include file="down.jsp"%>

</body>

</html>

 

0 0
原创粉丝点击