6

struts2 jspページのアクションメッセージとアクションエラーをどのように装飾するかについて、strutsを初めて使用します。

<s:actionmessage/>
<s:actionerror/>
4

3 に答える 3

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;
}
于 2012-05-18T10:16:17.813 に答える
2

こんにちはここで私はあなたのアクションメッセージとエラーメッセージを飾って欲しいならあなたの問題の解決策を投稿していますこのコードを使用してください

<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;
}
于 2012-05-08T05:27:44.473 に答える
1

レンダリング後にHTMLソースを表示して、Strutsがメッセージのレンダリングに使用するCSSクラスとHTML構造を確認する必要があります。テンプレートファイルを調べることもできます。

デフォルトでは、strutsは各アクションメッセージを次のようにレンダリングします。

<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テーマを使用している場合、これらのファイルはテンプレートの下のそのフォルダーにある可能性があります

于 2012-05-07T14:19:55.390 に答える