ダウンロードする – リンク://wp-content/uploads/2010/07/Struts2-Debug-Tag-Example.zip[Struts2-Debug-Tag-Example.zip]

Struts 2では、 ”

debug

“タグは ”

Value Stack

“の内容と ”

Stack Context

“の詳細をWebページに出力するための非常に便利なデバッグタグです。このチュートリアルでは、JSPページで ”

debug

“タグの使用方法を示します。

1.アクション



propertyInStack

“プロパティを持つシンプルなActionクラスは後で値のスタックに表示されます。

package com.mkyong.common.action;

import com.opensymphony.xwork2.ActionSupport;

public class DebugTagAction extends ActionSupport{

    public String propertyInStack;

    public String getPropertyInStack() {
        return propertyInStack;
    }

    public void setPropertyInStack(String propertyInStack) {
        this.propertyInStack = propertyInStack;
    }

}

2.日付タグの例

システムの ”

Value Stack

“と ”

Stack Context

“を出力するための ”

debug

“タグの使用を示すJSPページ。

  • debug.jsp **

<%@ taglib prefix="s" uri="/struts-tags" %>
 <html>
<head>
</head>

<body>
<h1>Struts 2 debug tag example</h1>

<s:debug/>

</body>
</html>

  • <s:debug/>

    は ”

    debug ** “という名前のテキストリンクを生成します。デバッグの詳細を拡張するには、テキストリンクをクリックする必要があります。

3. struts.xml

リンク〜

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <constant name="struts.devMode" value="true"/>
    <package name="default" namespace="/" extends="struts-default">

        <action name="debugTagAction"
            class="com.mkyong.common.action.DebugTagAction" >
            <result name="success">pages/debug.jsp</result>
        </action>

    </package>
</struts>

リファレンス

ドキュメンテーション]