red phoenix wrote:
I use struts2 <s:bean>,like follows:

---SimpleCounter---
package test;
public class SimpleCounter{
String foo;

public void setFoo(String foo){
 System.out.println("set foo="+foo);
 this.foo=foo;
}
public String getFoo(){
 System.out.println("get foo="+foo);
 return foo;
}
}

---test.jsp---
<%@ taglib uri="/struts-tags" prefix="s" %>
<s:bean name="test.SimpleCounter" id="counter">
  <s:param name="foo" value="BAR" />
  The value of foot is : <s:property value="foo"/>, when inside the bean
tag <br />
</s:bean>

When I run it,tomcat shows:
set foo=null
get foo=null

IE shows:
The value of foot is : , when inside the bean tag

I think <s:param name="foo" value="BAR" /> should call setFoo("BAR") and
should print set foo=BAR,I don't know why print set foo=null. Anyone can
tell me the reason of error.


I could be wrong, but I suspect s:param's 'value' attribute is evaluated as an expression, so you'd need to write

  <s:param name="foo" value="%{'BAR'}"/>

or, more simply,

  <s:param name="foo" value="'BAR'"/>

See the Tag Syntax document [1] for more details.

L.

[1] http://struts.apache.org/WW/tag-syntax.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to