2013-06-26 108 views
1

大家好我是Struts的新手,因爲我正在創建一個簡單的註冊應用程序,所以我被困在一個點上。(Struts)缺少密鑰「registration.jsp.title」的消息

以下是我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> 

我有我包含在/WEB-INF/resources文件夾 Application.properties文件,下面是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> 
+1

如果您是Struts的新手,爲什麼要從[正式EOL'd](http://struts.apache.org/struts1eol-announcement.html)版本開始?在任何情況下,在不包含屬性文件和文件位置的情況下詢問關於缺少密鑰的問題都無法提供幫助。 –

回答

0

你的應該在src文件夾中有Application.properties文件。此屬性文件應包含通過<bean:message>標記在JSP中獲得的消息的鍵值對。例如

registration.jsp.title = My registration title 

對於你通過檢索應該是使用標記的key屬性文件中唯一的關鍵此消息。