Struts2标签教程 标签
Struts2提供了大量丰富的标签供使用,它不再像Struts1中一样,将种类标签进行分门列别,但可以根据其使用的用途用以区别。本文通过对 Struts2中数据标签的学习,来对Struts2中标签的学习起到一个抛砖引玉的作用。文中将介绍Action标签、Bean标签、Data标签、 Include标签、Param标签、Set标签、Text标签、Property标签等标签。
代码下载:
Struts2DataTags
七、<s:property>标签
Property顾名思义,可以与<s:bean>标签结合使用,一个是给bean赋值,一个是从bean中读取值。直接来看示例:
1.WebRoot\pages\dataTags\propertyTag.jsp
<%@ page contentType=”text/html; charset=GBK” %>
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Property Tag 示例</title>
</head>
<body>
<h2>Property Tag 示例</h2>
<!– Example to pick the value through bean class –>
<s:bean name=”com.sterning.companyName” id=”uid”>
<s:param name=”name”>sterning</s:param>
<s:property value=”%{name}” /><br>
</s:bean>
<!– Default value –>
<s:property value=”name” default=”Default Value” />
</body>
</html>
2.Bean
当然这里用到了Bean. com\sterning\ companyName.java,代码如下:
package com.sterning;
public class companyName {
private String name;
public void setName(String name){
this.name =name ;
}
public String getName(){
return name;
}
}
3.src”com”sterning” propertyTag.java
进行页面跳转
package com.sterning;
import com.opensymphony.xwork2.ActionSupport;
public class propertyTag extends ActionSupport {
public String execute() throws Exception{
return SUCCESS;
}
}
4.Struts.xml配置
<action name=”propertyTag”>
<result>/pages/dataTags/propertyTag.jsp</result>
</action>


很丰富的内容,也很有用,学习了。
请问这是什么源码!
你好 这是struts2的标签