JSP学习笔记(六):包含页面
inc.jsp
<%@ page language="java" pageEncoding="GB2312"%>
<%!
public String Fun()
{
return "test";
}
%>
<%!
public String Fun()
{
return "test";
}
%>
code.jsp
<%@ page language="java" pageEncoding="GB2312"%>
<%@ include file="inc.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>title</title>
</head>
<body>
<%=Fun()%>
</body>
</html>
<%@ include file="inc.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>title</title>
</head>
<body>
<%=Fun()%>
</body>
</html>
效果相当于把inc.jsp文件的代码覆盖到code.jsp文件 <%@ include file="inc.jsp" %> 的位置处。