通过 HTTP 加载 Java 资源包
2009-12-24 00:00:00 来源:WEB开发网/AutoParts/
填充空缺部分
回忆一下示例应用程序概览,RemoteBundleDisplay.jsp 实例化类 MessagesBean。清单 3 显示 JSP 代码。
清单 3. RemoteBundleDisplay.jsp<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" import="remote.bundle.example.MessagesBean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<jsp:useBean id="messagesBean" scope="page"
class="remote.bundle.example.MessagesBean"></jsp:useBean>
<jsp:setProperty name="messagesBean" property="locale"
value="${pageContext.request.locale}"></jsp:setProperty>
<jsp:setProperty name="messagesBean" property="scheme"
value="${pageContext.request.scheme}"></jsp:setProperty>
<jsp:setProperty name="messagesBean" property="port"
value="${pageContext.request.serverPort}"></jsp:setProperty>
<jsp:setProperty name="messagesBean" property="host"
value="${pageContext.request.serverName}"></jsp:setProperty>
<jsp:setProperty name="messagesBean" property="refererHeader"
value='${header["Referer"]}'></jsp:setProperty>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Displays messages from resource bundles located in other Web
Applications</title>
</head>
<body>
<p>The Messages:</p>
<ul>
<c:forEach var="msg" items="${messagesBean.messagesMap}">
<li>${msg.value}</li>
</c:forEach>
</ul>
</body>
</html>
更多精彩
赞助商链接