JSP 包含国际化标签
JSP includes tags for internationalization
我的 JSP (template.jsp) 中有这个结构:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="language" value="es" scope="session"/>
<fmt:setBundle basename="com.myweb.i18n.text"/>
<html>
<body>
<fmt:message key='login.label.username'/>
<jsp:include page='/home/header.jsp' flush='true'/>
<jsp:include page='/home/body.jsp' flush='true'/>
<jsp:include page='/home/footer.jsp' flush='true'/>
</body>
</html>
fmt:message 行效果很好(打印文本标签)。但是,如果我在 header.jsp 或任何其他包含的 jsp 中写下这一行,则不起作用。
我必须在所有 jsp 文件中写入所有标记库行吗?
有什么方法可以包含而不重复我所有 jsp?
中的前 4 行
谢谢!
编辑:示例 header.jsp
<div>
<fmt:message key='login.label.username'/>
<jsp:include page='/home/header-left.jsp' flush='true'/>
<jsp:include page='/home/header-center.jsp' flush='true'/>
<jsp:include page='/home/footer-right.jsp' flush='true'/>
</div>
将行放入 jsp 并将其包含在当前 jsp i;e template.jsp as
<@include file="path/jspcontaininglibs.jsp"/>
<html>
<body>
<fmt:message key='login.label.username'/>
<jsp:include page='/home/header.jsp' flush='true'/>
<jsp:include page='/home/body.jsp' flush='true'/>
<jsp:include page='/home/footer.jsp' flush='true'/>
</body>
</html>
我的 JSP (template.jsp) 中有这个结构:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="language" value="es" scope="session"/>
<fmt:setBundle basename="com.myweb.i18n.text"/>
<html>
<body>
<fmt:message key='login.label.username'/>
<jsp:include page='/home/header.jsp' flush='true'/>
<jsp:include page='/home/body.jsp' flush='true'/>
<jsp:include page='/home/footer.jsp' flush='true'/>
</body>
</html>
fmt:message 行效果很好(打印文本标签)。但是,如果我在 header.jsp 或任何其他包含的 jsp 中写下这一行,则不起作用。
我必须在所有 jsp 文件中写入所有标记库行吗? 有什么方法可以包含而不重复我所有 jsp?
中的前 4 行谢谢!
编辑:示例 header.jsp
<div>
<fmt:message key='login.label.username'/>
<jsp:include page='/home/header-left.jsp' flush='true'/>
<jsp:include page='/home/header-center.jsp' flush='true'/>
<jsp:include page='/home/footer-right.jsp' flush='true'/>
</div>
将行放入 jsp 并将其包含在当前 jsp i;e template.jsp as
<@include file="path/jspcontaininglibs.jsp"/>
<html>
<body>
<fmt:message key='login.label.username'/>
<jsp:include page='/home/header.jsp' flush='true'/>
<jsp:include page='/home/body.jsp' flush='true'/>
<jsp:include page='/home/footer.jsp' flush='true'/>
</body>
</html>