Hi,
The debug tag is "inspecting" the status of your action to build its
HTML output, which include knowing the value of test1, and thus calling
the corresponding getter.
Take out the debug tag, and everything should be back to normal.
Denis.
Gábor Kovács a écrit :
Hi everyone,
I'm confused, because I don't understand this problem:
I've made a simple Struts2 project. Here are the codes (they're short)
ACTION CLASS
---------------------------
package test.action;
import com.opensymphony.xwork2.ActionSupport;
public class TestAction extends ActionSupport{
public String getTest1(){
System.out.println("getTest1");
return SUCCESS;
}
}
STRUTS.XML
------------------------
<struts>
<package name="test" extends="struts-default">
<action name="test" class="test.action.TestAction">
<result>/test.jsp</result>
</action>
</package>
</struts>
WEB.XML
-----------------------
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="
http://java.sun.com/xml/ns/javaee" xmlns:web="
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
<display-name>TEST</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>test.jsp</welcome-file>
</welcome-file-list>
</web-app>
TEST.JSP
------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
.
.
.
.
<style> .errorMessage { color:red; }</style>
</head>
<body>
<s:url id="test" namespace="/test" action="test" />
<s:a href="%{test}">TEST</s:a>
<s:debug/>
</body>
</html>
----------------------------------------------------------------------------------------------------------------------------
When I click the link which calls the action named test, I expect that:
Struts can see the struts.xml, then calls the TestAction's execute method().
Yes, it does, but besides, it calls the TestAction's getTest1() method (it
writes "getTest1" to the console)...and if I write another method, which is
public and it's return type is String AND it has a GET prefix (getFOO)
....it will be called, too.
I don't get it...Why?
Thanks in advance!
Gábor
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org