在Struts 2中,“ debug ”标记是非常有用的调试标记,用于输出网页中“ Value Stack ”的内容以及“ Stack Context ”详细信息。 在本教程中,它显示了JSP页面中“ debug ”标记的用法。
1.行动
带有“ propertyInStack ”属性的简单Action类稍后将在值堆栈中显示。
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.日期标签示例
一个JSP页面,显示使用“ debug ”标记来输出系统的“ Value Stack ”和“ 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>
<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>
4.演示
http:// localhost:8080 / Struts2Example / debugTagAction.action
输出量
参考
标签: struts2