2010-12-28 6 views
0

messages.propertiesファイルからクライアント側の検証用のエラーメッセージ値を取得し、それをページに表示する必要があります。 私は<fmt:message key="uname.prop" />を使用しました。.propertiesファイルからエラーメッセージ値を取得する

<script type="text/javascript"> 
    $(document).ready(function() { 
    $("#userRegistrationDetails").validate({ 
     rules: { 
     username: "required", 
     email: { 
     required : true, 
     email : true 
       }, 
     password: "required", 
     confpass: { 
     required :true, 
     equalTo: "#password" 
       } 
       }, 
    messages: { 
     username: <fmt:message key="uname.prop" />, 
     email: "Please enter valid email address", 
     password: "Please enter the password", 
     confpass: "Please enter the same password" 
     } 

    }); 
    }); 

私のフォームページにあります。

ラベル属性は春に定義されていないため使用できません。

+0

あなたの質問がありますか?どのような「ラベル属性」を参照していますか? – skaffman

答えて

1

あなたがusernameのメッセージをどのように定義したのかと同じように、メールやその他のフィールドで同じことをするのはなぜですか?

messages: { 
    username: <fmt:message key="uname.prop" />, 
    email: "<fmt:message key="error.invalid.email"/>", 
    password: "<fmt:message key="error.required.password"/>", 
    ... 
} 
+0

彼の全面的な問題は、 'username:username:の代わりに有効なユーザー名を入力してください。 'のような無効なJavascriptとして終わるように引用していないということでした。 – BalusC

1

あなたが引用符で囲まれた文字列を取得する必要がある場合は、引用符で囲み必要があります。

username: "<spring:message code = 'uname.prop' javaScriptEscape = 'true' />", 

はまた、あなたは、Javascriptのソースを生成しているので、あなたが適切なエスケープ処理を適用する必要があることに注意してください。 Javascriptエスケープは<spring:message>でサポートされているので、<fmt:message>ではなくそれを使用するのが理にかなっています。

+0

'javaScriptEscape'は[' fmt:message'](http://download.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fmt/tld-summary.html)の一部ではありませんが、[' spring:message'](http://static.springsource.org/spring/docs/2.5.x/reference/spring.tld.html#spring.tld.message)。 – BalusC

+0

@BalusC:ありがとう、固定。 – axtavt

関連する問題