什么相当于struts 2中的<bean:define> </bean:define>

时间:2014-11-21 11:36:01

标签: java struts2

下面是用struts1 JSP页面编写的代码行,以及将它转换为Struts2 JSP页面的内容。

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>

<bean:define id="clientOptions" name="XYZ" property="clients" type="java.util.Iterator"/>

<html:select name="XYZ" property="id" onfocus="SCV(this.selectedIndex)" onchange="selectClient(this)">
     <html:options collection="clientOptions" labelProperty="name" property="id" />
</html:select>

有人可以告诉我,struts2中的等效代码是什么?

2 个答案:

答案 0 :(得分:1)

我认为你可以使用:

<s:set var="newVariable" value="bean.property"/>

这里有doc:

http://struts.apache.org/release/2.3.x/docs/set.html

答案 1 :(得分:0)

等效代码是

<%@ taglib prefix="s" uri="/struts-tags" %>

<s:select id="XYZ" name="id" list="clients" listKey="id" listValue="name" onfocus="SCV(this.selectedIndex)" onchange="selectClient(this)"/>
相关问题