2012-05-07 14 views
6

struts2のJSPページでアクションメッセージとアクションエラーをどのように飾るのですか?アクションメッセージtag in struts2

<s:actionmessage/> 
<s:actionerror/> 
+1

シンプルなテーマを使用して、希望するCSSスタイルを適用できます。 –

答えて

4

使用にこのコードを飾るために、あなたのアクションメッセージとエラーメッセージをしたい場合は、あなたのアクションエラーとアクションメッセージを飾るためにCSSスタイルだけでなく、jQueryのテーマ属性を使用することができます。

<div class="error"><s:actionerror theme="jquery"/></div> 
<div class="message"><s:actionmessage theme="jquery"/></div> 

.message li 
{ 
    font-size: 14px; 
    color: #000066; 
    text-align: center; 
    list-style: none; 
    font-family: Trebuchet MS,sans-serif,inherit,Arial,monospace; 
} 

.error li 
{ 
    font-size: 14px; 
    color: #990000; 
    text-align: center; 
    list-style: none; 
    padding-right: 50px; 
} 
1

Strutsのメッセージをレンダリングするために使用するCSSクラスとHTMLの構造を見るためにレンダリングされた後は、HTMLソースを表示する必要があります。また、テンプレートファイルを見ることもできます。次のようにデフォルトの支柱によって

は、各アクションのメッセージをレンダリング:

<ul> 
    <li><span class="actionMessage">${message}</span></li> 
</ul> 

すべてのメッセージが<li><span class="actionMessage">${message}</span></li>を持つことになります。

actionMessageのCSSを作成したり、必要に応じてレンダリングするようにテンプレートファイルを変更することができます。

/template/simple/actionerror.ftl 
/template/simple/actionmessage.ftl 

フィールドのエラーが同様にあなたの役に立つかもしれません:

/template/simple/fielderror.ftl 

注:あなたはXHTMLテーマに、それらのファイルを使用している場合、これらのための

テンプレートファイルは次の場所にあります。 はテンプレートの下のフォルダにあります

+0

struts2のUIタグでは、スタイリングの目的でスタイル、ID、クラスの属性を追加することもできます。 – Quaternion

2

こんにちは、私は投稿していますあなたの問題のolutionあなたは

<div id="sucessMsg"><s:actionerror /></div> 


sucessMsg is the class that is using by struts2 internally so override this so kindly put the below code inside the css 

#sucessMsg { 
    text-align: center; 
    font-weight: bolder; 
    color: #6A2A91; 
    list-style: none; 
    margin: auto; 
} 

#errorMsg { 
    text-align: center; 
    font-weight: bolder; 
    color: red; 
    list-style: none; 
    width: 350px; 
    margin: auto; 
}