DebugTagAction.java
package com.tw511.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; } }
debug.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> </head> <body> <h1>Struts2 <s:debug>標籤範例 - www.tw511.com</h1> <s:debug /> </body> </html>
<?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.tw511.common.action.DebugTagAction" > <result name="success">pages/debug.jsp</result> </action> </package> </struts>
http://localhost:8080/struts2debugtag/debugTagAction.action
在瀏覽器中開啟上面的網址,輸出結果如下:
下載程式碼 - http://pan.baidu.com/s/1gdEvJGZ