java - 缺少 key "registration.jsp.title"的消息

标签 java jsp struts struts-1 xml-configuration

我正在创建一个简单的注册应用程序,但我陷入了困境。

以下是我的index.jsp文件

index.jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html:html>

<head>
    <title><bean:message key="registration.jsp.title"/></title>
    <style type="text/css">
        .error { color: red; font-weight:bold }
    </style>
</head>    
<body>
    
    <h1><bean:message key="registration.jsp.heading"/></h1>

    <logic:present name="registration-successful" scope="request">
        <h2>    
            <bean:message key="registration.jsp.registration-successful"/>   
            <bean:write name="registration-successful" property="userid" />
        </h2>
    </logic:present>

    <logic:notPresent name="registration-successful" scope="request">
        <html:form action="Registration.do" focus="userid">

            <dl>
                <dt><bean:message key="registration.jsp.prompt.userid"/></dt>            
                <dd>
                    <html:text property="userid" size="20" />
                    <span class="error"><html:errors property="userid" /></span>
                </dd>

                <dt><bean:message key="registration.jsp.prompt.password"/></dt>            
                <dd>
                    <html:text property="password" size="20" />
                    <span class="error"><html:errors property="password" /></span>    
                </dd>

                <dt><bean:message key="registration.jsp.prompt.password2"/></dt>            
                <dd><html:text property="password2" size="20" /></dd>

                <dt><html:submit property="submit" value="Submit"/>
                    <html:reset/>
                </dt>            
            </dl>
                    
        </html:form>
    </logic:notPresent>

</body>
</html:html>

我的 Application.properties 文件包含在 /WEB-INF/resources 文件夹中 以下是 struts-config.xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>

<form-beans>
    <form-bean name="RegistrationForm"            
type="net.thinksquared.registration.RegistrationForm"/>          
</form-beans>

<action-mappings>

    <action path="/Registration"
            type="net.thinksquared.registration.RegistrationAction"
            name="RegistrationForm"
            scope="request"
            validate="true"
            input="/index.jsp">

        <forward name="success" path="/index.jsp"/>

    </action>

</action-mappings>

<message-resources parameter="Application"/>

</struts-config>

最佳答案

你应该有Application.properties文件在src文件夹中。该属性文件应包含您通过 <bean:message> 在 JSP 中获取的消息的键值对。标签。例如

registration.jsp.title = My registration title

并且您可以使用key通过文件中应该唯一的键检索此消息标签的属性。

关于java - 缺少 key "registration.jsp.title"的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17318577/

相关文章:

java - 在 tomcat 7 运行时启动 tomcat 6 的问题

java - 使用 DisplayTag 时如何自定义 paging.banner.some_items_found

当我想要所有时,Java 正则表达式只找到最后一个匹配项

css - 根据 servlet 的值更改表行的颜色

jsp - 使用c :forEach over sling:listChildren

java - JSTL:用空格格式化字符串数字

java - Maven安装j2ee文件夹结构问题(spring,struts..)

java - 如何比较日期 - 自定义格式 "dd.MM.yyyy, HH:mm:ss"中的字符串与另一个?

java - 创建多个子对象是否也强制在 java 中创建多个父对象?

java - 通过一个Database类访问数据库,紧耦合?破坏建议零售价?