Add header and bottom to jsp page, set background

Add header and bottom to jsp page, set background

Precautions:

Header and footer file encoding issues;

Include the header file and the bottom file with include <%@ include file = "xx.jsp" %>

Path problem when setting background image

 

Header file: 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;">

 < td style = " align : center ; " > Homepage </td>

 < td style = "" > Recruitment information </td>

 < td style = " " > Announcement </td>

 < td style =" " > Contact us </td>

 < td style = "" > Enterprise product </td>

</tr>

</table>

Bottom file: down.jsp

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

    pageEncoding="UTF-8"%>

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

 Contact us: 000000-5555555-55555 </ br >

xxxxxxxxxxx -tech

</div>

Merge the above two pages and set the background image at the same time

<%@ 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 here</title>

</head>

<style>

body{

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

}

</style>

<body>

<%-- Load header and footer --%>

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

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

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

</body>

</html>

 

Guess you like

Origin blog.csdn.net/qi95719/article/details/53366129