【问题标题】:struts resource bundle properties file not mapping some keysstruts资源包属性文件未映射某些键
【发布时间】:2014-01-25 15:30:03
【问题描述】:

我开始研究struts,使用资源属性文件有问题

页面上的一些文字显示如下:

???login.message???
???login.username???    
???login.password???

但其他一些消息是从属性文件中正确获取的。我认为propertis文件配置正确,但我缺少正确显示任何东西的东西。

文件 ApplicationResources.properties

# Resources for Login Project

# Struts Validator Error Messages
# These two resources are used by Struts HTML tag library
# to format messages. In this case we make sure that errors
# are red so that they can be noticed.
errors.header=<font color="red">* 
errors.footer=</font>

#errors associated with the Login page
error.username.required=username required.
error.password.required=password required
error.login.invalid=The system could not verify your username or password. Is your CAPS LOCK on? Please try again.

#login page text
login.title=this is a title
login.message=please log in

login.username=username:
login.password=password:
login.button.signon=Log In

#loggedin page text
loggedin.title=Login Project
loggedin.msg=Benvenuto, {0}. You are now logged in.

“error.login.invalid”正确显示,“error.username.required”也正确显示

登录标签不是

这是我的jsp页面

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<html:html locale="true"/>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<fmt:bundle basename="ApplicationResources"/>
<title><fmt:message key="login.title"/></title>

</head>
<body>
<html:errors property="login"/>
<html:form action="login.do" focus="userName" >
<table align="center">
        <tr align="center">
            <td><H1><fmt:message key="login.message"/></H1></td>
        </tr>
        <tr align="center">
            <td>
                <table align="center">
                    <tr>
                        <td align="right">
                            <fmt:message key="login.username"/>
                        </td>
                        <td align="left">
                            <html:text  property="userName" 
                                        size="15" 
                                        maxlength="15" />
                            <html:errors property="userName" />
                        </td>
                    </tr>   
                    <tr>
                        <td align="right">
                            <fmt:message key="login.password"/>
                        </td>
                        <td align="left">
                            <html:password  property="password" 
                                            size="15" 
                                            maxlength="15" 
                                            redisplay="false"/>
                            <html:errors property="password" />
                        </td>
                    </tr>   
                    <tr>
                        <td colspan="2" align="center">
                            <html:submit>
                                <fmt:message key="login.button.signon"/>
                            </html:submit>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>


</html:form>





</body>
</html>

你能帮帮我吗? tkz

【问题讨论】:

    标签: java jsp properties struts


    【解决方案1】:

    你的

    <fmt:message ... />
    

    标签必须在一个

    <fmt:bundle ... >
    

    标签。目前你正在关闭你的bundle 标签

    <fmt:bundle basename="ApplicationResources"/>
    

    打开它

    <fmt:bundle basename="ApplicationResources">
    

    然后关闭它

    </fmt:bundle>
    

    当您不再需要它时,可能在您的 JSP 结束时。嵌套你的

    <fmt:message key="login.title"/>
    

    里面有标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-09
      • 1970-01-01
      • 2015-10-01
      相关资源
      最近更新 更多