format.jsp
来自「jakarta-taglibs」· JSP 代码 · 共 73 行
JSP
73 行
<%--
this page contains a variety of demonstrations of the <i18n:formatXXX> tags
--%>
<%@ taglib uri="http://jakarta.apache.org/taglibs/i18n-1.0" prefix="i18n" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.Locale" %>
<html>
<head>
<title>Examples of using the Formatting tags in the i18n Tag Library Tag</title>
</head>
<body>
<%
Number n = new Double( 1234567.89 );
Date d = new Date();
%>
<h2>Default Locale (<%= pageContext.findAttribute("userLocale") %>)</h2>
<i18n:locale localeRef="userLocale">
<%@ include file="format_include.jsf" %>
</i18n:locale>
<h2>US Locale</h2>
<i18n:locale locale="<%= Locale.US %>">
<%@ include file="format_include.jsf" %>
</i18n:locale>
<h2>FRANCE Locale</h2>
<i18n:locale locale="<%= Locale.FRANCE %>">
<%@ include file="format_include.jsf" %>
</i18n:locale>
<%
String country = request.getParameter( "country" );
if ( country == null ) {
country = "CH";
}
String language = request.getParameter( "language" );
if ( language == null ) {
language = "fr";
}
%>
<h2>Country: <%= country %> and Language: <%= language %></h2>
<i18n:locale country="<%= country %>" language="<%= language %>">
<%@ include file="format_include.jsf" %>
</i18n:locale>
<h2><formatString> example</h2>
<%
String s = "hello";
String s2 = null;
%>
<p>A non-null String is:
<b>
<i18n:formatString value="<%= s %>"/>
</b>
</p>
<p>A null String is:
<b>
<i18n:formatString value="<%= s2 %>" defaultText="the String was null"/>
</b>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?