JSP学习笔记(六十五):使用struts2中的s:bean标签
先添加一个bean:
Test1.java
package test;
public class Test1 {
private String str;
public String getStr() {
return str;
}
public void setStr(String str) {
this.str = str;
}
public String hello()
{
return "Hello World!";
}
public String hello(String name)
{
return "Hello," + name;
}
}
然后就可以使用这个bean了:
<s:bean name="test.Test1" id="mybean">
<s:param name="str" value="'abc'"></s:param>
</s:bean>
<s:property value="#mybean.str"/><br/>
<s:property value="#mybean.hello()"/><br/>
<s:property value="#mybean.hello('tom')"/>