⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locale.jsp

📁 Struts+Spring+Hibernate开发的BBS,功能很强大很完善
💻 JSP
字号:
<%
/**
 *	$RCSfile: locale.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:28 $
 */
%>

<%@ page import="java.util.*,
				 java.text.*,
				 com.jivesoftware.util.*,
                 com.jivesoftware.forum.*,

				 com.jivesoftware.forum.util.*"
%>

<%@ include file="include/global.jsp" %>

<%! // Global vars, methods, etc

    // All locales
    static Locale[] LOCALES = Locale.getAvailableLocales();
    static {
        Arrays.sort(LOCALES, new Comparator() {
            public int compare(Object o1, Object o2) {
                Locale loc1 = (Locale)o1;
                Locale loc2 = (Locale)o2;
                return loc1.getDisplayName().compareTo(loc2.getDisplayName());
            }
        });
    }
%>

<%	// get parameters
    String localeCode = ParamUtils.getParameter(request,"localeCode");
    boolean saveLocale = ParamUtils.getBooleanParameter(request,"saveLocale");

    // save the locale if requested
    if (saveLocale) {
        // parse the incoming locale code
        String language = null;
        String country = null;
        String variant = null;
        if (localeCode != null) {
            StringTokenizer tokenizer = new StringTokenizer(localeCode, "_");
            if (tokenizer.hasMoreTokens()) {
                language = tokenizer.nextToken();
                if (tokenizer.hasMoreTokens()) {
                    country = tokenizer.nextToken();
                    if (tokenizer.hasMoreTokens()) {
                        variant = tokenizer.nextToken();
                    }
                }
            }
        }
        Locale newLocale = new Locale(
            language,
            ((country!=null)?country:""),
            ((variant!=null)?variant:"")
        );
        // finally, set the new jive locale
        JiveGlobals.setLocale(newLocale);
        // we're done so redirect back to this page
        response.sendRedirect("locale.jsp");
        return;
    }

    // Get Jive's global locale
    Locale locale = JiveGlobals.getLocale();

    // Current date
    Date date = new Date();

    // Set the locale in the response object
    response.setLocale(locale);
%>

<%@ include file="include/header.jsp" %>

<p>

<%  // Title of this page and breadcrumbs
    String title = "Locale Settings";
    String[][] breadcrumbs = {
        {"Main", "main.jsp"},
        {"Locale Settings", "locale.jsp"}
    };
%>
<%@ include file="include/title.jsp" %>

<font size="-1">
Edit the global locale below, which controls the way dates and times are formatted
by Jive Forums.
</font>

<p>

<font size="-1"><b>Current Locale</b></font>
<ul>
    <font size="-1">
    The curent locale is <b><%= locale.getDisplayName() %></b>
    <p>
    <table cellpadding="2" cellspacing="0" border="0">
    <tr>
    	<td><font size="-1">Sample Date:</font></td>
    	<td><font size="-1"><b><%= JiveGlobals.formatDate(date) %></b></font></td>
    </tr>
    <tr>
    	<td><font size="-1">Sample Date and Time:</font></td>
    	<td><font size="-1"><b><%= JiveGlobals.formatDateTime(date) %></b></font></td>
    </tr>
    </table>
    <p>
    </font>
</ul>

<p>

<font size="-1"><b>Locale Settings</b></font>
<ul>
    <form action="locale.jsp">
    <input type="hidden" name="saveLocale" value="true">
    <table cellpadding="3" cellspacing="0" border="0">
    <tr>
    	<td><font size="-1">Locale:</font></td>
        <td>
            <select size="1" name="localeCode">
        <%  for (int i=0; i<LOCALES.length; i++) {
                String selected = "";
                if (locale.equals(LOCALES[i])) {
                    selected = " selected";
                }
        %>
            <option value="<%= LOCALES[i].toString() %>"<%= selected %>><%= LOCALES[i].getDisplayName() %>
        <%  } %>
            </select>
        </td>
    </tr>
    <tr>
    	<td>&nbsp;</td>
        <td>
            <input type="submit" value="Save Global Locale">
        </td>
    </tr>
    </table>
    </form>
</ul>

<p>

<%@ include file="include/footer.jsp" %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -