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

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-55555br>

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+"/";

%>   

DOCTYPEhtml PUBLIC "-//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 heretitle>

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>

 

你可能感兴趣的:(jsp)