[英]JSP include other jsp page
例如我做了三個這樣的jsp
文件
example1.jsp
<%
HashMap<String, String> map = new HashMap<String, String>();
map.put(test1);
map.put(test2);
%>
--
example2.jsp
<%
out.print(map.get(test1));
%>
--
example3.jsp
<%
out.print(map.get(test2));
%>
我想在example1.jsp
使用變量映射聲明和
在exmple2.jsp
和exmaple3.jsp
我如何使用這樣的變量?
您可以使用<%@include file="example2.jsp" %>
和<%@include file="example3.jsp" %>
在您的第一個JSP。 基本上,您正在做的是靜態包含兩個jsp文件。 在第一個jsp中聲明的變量將在第二個和第三個jsp中可見。
如果您執行jsp include,則第一個jsp中定義的變量將在第二個和第三個jsp中不可見,因為它是動態包含
查看更多詳細信息<jsp:include page = ...>和<%@ include file = ...>之間有什么區別?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.