例如,我制作了三个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和
使用at exmple2.jsp和exmaple3.jsp
我如何使用这样的变量?
发布于 2013-11-22 06:21:36
您可以在第一个jsp中使用<%@include file="example2.jsp" %>和<%@include file="example3.jsp" %>。基本上,您所做的是静态地包括两个jsp文件。在第一个jsp中声明的变量将在第二个和第三个jsp中可见。
如果您执行jsp包含,那么第一个jsp中定义的变量在第二个jsp和第三个jsp中将不可见,因为它是一个动态包含。
请参阅更多详细信息What is the difference between and <%@ include file = ... >?
https://stackoverflow.com/questions/20138185
复制相似问题