Struts 2 debug tag example
In Struts 2, the “debug” tag is a very useful debugging tag to output the content of the “Value Stack” and also the “Stack Context” details in the web page. In this tutorial, it shows the use of “debug” tag in JSP page.
1. Action
A simple Action class, with a “propertyInStack” property, show in value stack later.
DebugTagAction.java
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. date tag example
A JSP page to show the use of “debug” tag to output the system’s “Value Stack” and “Stack Context“.
debug.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> </head> <body> <h1>Struts 2 debug tag example</h1> <s:debug /> </body> </html>
3. struts.xml
Link it ~
<?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>
4. Demo
http://localhost:8080/Struts2Example/debugTagAction.action
Output






