原文地址:http://my.oschina.net/jgy/blog/50802
debug標簽主要用於輔助測試,它在頁面上生成一個超鏈接,通過該鏈接可以查看ValueStack和Stack Context 中的所有值信息。使用debug標簽只有一個id屬性,這個屬性僅僅是該元素一個引用id。 在頁面上增加<s:debug/>標簽,通過debug標簽,可以看的系統中ValueStack離得全部信息,並可以看到Stack Context中的屬性。
result.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'result.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
username:<s:property value="username"/><br>
password:<s:property value="password"/><br>
<s:debug></s:debug>
</body>
</html>
我們可以看到.它提供的是Struts ValueStack Debug ..也就是說,都是struts2的值棧(就是各個值的信息)..
這個值棧又分為兩種.Value Stack Contents 和 Stack Context .
(1).Value Stack Contents 里面的信息我們可以用 <s:property value="sss"> 這樣來直接訪問.
(2) Stack Context 里面的信息我們可以 <s:property value="#sss">這樣來訪問