JavaWeb公共页面提取

JavaWeb公共页面提取

使用jsp命令<%@ include%>

<%@ include file="common/header.jsp"%>
<h1>网页主体</h1>
<%@ include file="common/footer.jsp"%>

使用jsp标签

<jsp:include page="/common/header.jsp"></jsp:include>
<h1>网页主体</h1>
<jsp:include page="/common/footer.jsp"></jsp:include>

两种方法的区别

<%@ include%>

在jsp变为java文件时,会将 "@include"所指向的jsp页面和本页面组合到一起放在service方法中

<jsp: include pafge=>

在jsp变为java文件时,会将引用的页面放在类里面,置为类的static资源,之后再service中进行引用,本质为拼接页面。

猜你喜欢

转载自blog.csdn.net/m0_53509974/article/details/114590211