[英]Is it possible to run <jsp:include> run after / async with the other html in a jsp?
在这种情况下,我的导航加载时间很长。
在下面的这段代码中。 还有其他 jsp “侧面导航”。
是否可以与其他 html 身体标签异步运行“侧面导航”? 或者是否可以在其他 html 节目之后运行“侧面导航”?
预期:“欢迎”措辞在/异步导航完成加载之前显示
<body class="nav-md">
<div class="container body">
<div class="main_container">
<jsp:include page='_Side_Navigation.jsp'></jsp:include>
<div class="right_col" role="main">
<div class="alert alert-success" style="margin-top: 60px;">Welcome</div>
</div>
<jsp:include page='_Footer_Note.jsp'></jsp:include>
</div>
</div>
</body>
这是一个演示 JSP。
Here is the first part of page.
Navigation part will come after a delay for demonstration.<br>
<iframe id="nav" title="nav" src="${pageContext.request.contextPath}/nav">
</iframe>
Here is the last part of page.
我在我的 web 应用程序的 web.xml 文件中映射了我的导航文件。
<servlet>
<servlet-name>myNav</servlet-name>
<jsp-file>/WEB-INF/nav.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>myNav</servlet-name>
<url-pattern>/nav</url-pattern>
</servlet-mapping>
这是我用于测试的 nav.jsp 文件。
<%!
String pause() throws InterruptedException {
Thread.sleep(2000);
return "imported from nav.jsp after 2 second delay";
}
%>
<%=pause()%>
如果您的 WEB-INF 文件夹中没有导航文件,那么您就不必 map 了。 在此解决方案中,浏览器发出两个请求。 一个请求主页,另一个请求 iframe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.