我有一个jsp“模板”视图,其中包含来自其他几个jsp的内容。来自其他jsp的内容被包含在模板文件中的<div>
中。
在包含的jsp中,我希望有一个名为“popup”(或其他)的超链接。单击此链接时,此包含的jsp的内容将“弹出”模板jsp并打开到其自己的窗口中。
e.g:
template.jsp:
<body>
<div>
//include jsp-1.jsp
</div>
<div>
//include jsp-2.jsp
</div>
</body>
的jsp-1.jsp页面:
<p>
...
<a href="">Pop out</a> //Clicking this will open a new window
//containing only the contents of jsp-1.jsp
</p>
答案 0 :(得分:0)
这不应该太难。我不确定你是否设置了它以便浏览器直接请求JSP文件,但如果是这样,这样的东西应该对你有用:
的jsp-1.jsp页面:
<p>
...
<a href="/jsp-1.jsp" target="_blank">Pop out</a>
</p>
编辑:关于丢失CSS和JS文件的评论,这就是我如何解决这个服务器端的问题。它有点难看,但效果还不错。
<html>
<head>
...
</head>
<body>
<c:set var="ContentOnly" value="true" scope="request"/>
<div>
<jsp:include page="jsp-1.jsp" />
</div>
<div>
<jsp:include page="jsp-2.jsp" />
</div>
<c:remove var="ContentOnly" scope="request"/>
</body>
</html>
<c:if test="${(empty ContentOnly) or (not ContentOnly)}">
<html>
<head>
...
<!-- jsp-1 required CSS and JS here -->
<!-- these will only be included when the page is requested as "standalone" -->
...
</head>
<body>
</c:if>
...
<!-- jsp-1 content here -->
...
<c:if test="${(empty ContentOnly) or (not ContentOnly)}">
</body>
</html>
</c:if>
答案 1 :(得分:0)
使用javascript window.open