I am using Tiles within my web-application. I have a standard-layout (standard.jsp) within the tiles are used. On top of the standard.jsp are a lot of includes, concerning tag-libraries and such.
我在我的网络应用程序中使用Tiles。我在tile中使用了标准布局(standard.jsp)。在standard.jsp之上有很多包括标签库等。
Let's do a simplified example.
我们来做一个简化的例子。
standard.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/includes/include.jsp" %>
<html>
<head>
<tiles:insertAttribute name="head" flush="false"/>
</head>
<body>
<tiles:insertAttribute name="body" flush="false"/>
</body>
</html>
body.jsp:
<div id="body-div">
<p>Hello, <c:out value="${forname}" />!</p>
</div>
This prints:
Hello, !
In the tiles I would like to use the tags, but it's not working. It only works, if I add the includes to the tile-jsp.
在瓷砖我想使用标签,但它不起作用。它只有在我将tile包含添加到tile-jsp时才有效。
body.jsp with includes:
body.jsp包括:
<%@ include file="/WEB-INF/jsp/includes/include.jsp" %>
<div id="body-div">
<p>Hello, <c:out value="${forname}" />!</p>
</div>
This prints:
Hello, John!
Is there a better way to do this or do I have to add all includes to every jsp used?
有没有更好的方法来做到这一点,或者我必须将所有包含添加到每个使用的jsp?
1 个解决方案
#1
You don't need ALL includes to be present in each of your tiles, but each used tag-library in a tile must specifically be included in the using tile.
您不需要在每个图块中都包含所有包含,但是图块中每个使用的标记库必须特别包含在使用图块中。
eg : In your example, each tile using the C JSTL library should at least have the <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
include
例如:在您的示例中,使用C JSTL库的每个tile应该至少包含<%@ taglib uri =“http://java.sun.com/jsp/jstl/core”prefix =“c”%> include
#1
You don't need ALL includes to be present in each of your tiles, but each used tag-library in a tile must specifically be included in the using tile.
您不需要在每个图块中都包含所有包含,但是图块中每个使用的标记库必须特别包含在使用图块中。
eg : In your example, each tile using the C JSTL library should at least have the <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
include
例如:在您的示例中,使用C JSTL库的每个tile应该至少包含<%@ taglib uri =“http://java.sun.com/jsp/jstl/core”prefix =“c”%> include