tag标记参数

tag标记参数
2009年07月27日 星期一 下午 4:38
rtexprvalue的全称是 Run-time Expression Value, 它用于表示是否可以使用JSP表达式.

当在<attribute>标签里指定<rtexprvalue>true</rtexprvalue>时, 表示该自定义标签的某属性的值可以直接指定或者通过动态计算指定, example as follow:

<sql:query var="result" >
    select * from mytable order by nameid
</sql:query>
<%request.setAttribute("nameid", "2"); %>
<myTag:cupSize cupSize="1" cupSizes="${result}"></myTag:cupSize>
<myTag:cupSize cupSize="${nameid}" cupSizes="${result}"></myTag:cupSize>


当在<attribute>标签里指定<rtexprvalue>false</rtexprvalue>时, 表示该自定义标签的某属性的值只能直接指定, example as follow:
<myTag:cupSize cupSize="1" cupSizes="${result}"></myTag:cupSize>
TLD文件配置详解(jsp自定义标签)

<tag>
<name>write</name>
<tagclass>org.apache.struts.taglib.bean.WriteTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>bundle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>其中:
<name>write</name>:这个Tag的名字
<tagclass>org.apache.struts.taglib.bean.WriteTag</tagclass>:这个Tag是由那个类实现的(这个class可以在struts.jar包中找到)
<bodycontent>empty</bodycontent>:这个Tag可以直接结尾,不需要填写内容
   这里bodycontent有三个可选值
       jsp        标签体由其他jsp元素组成  
         如果其有jsp元素,那么标签会先解释,然后将元素的实际值传入。比如标签体里含有<%=attributeName%>这样子的jsp元素,此时标签会按attributeName的实际值是什么就传入什么。这个是最常用的一个。
       empty 标签体必须为空  
         在引用这个Tag的时候,可以<bean:write bundle="attributeName" />,而不必<bean:write bundle="attributeName" ></bean:write>
       tagdependent 由标签解释,不带jsp转换
<attribute> </attribute>这里标识的是这个Tag的一个参数
<name>bundle</name>这个参数的名字
<required>false</required>这个参数是否是必填相
      如果为true则必须写这个参数,否则会报错
<rtexprvalue>true</rtexprvalue>是说这个标签的值可以写入
       rtexprvalue:"RUN-TIME EXPRESSION VALUE",是否可以动态赋值,在jsp中如value="<%=attributeName%>"

猜你喜欢

转载自weiboxie.iteye.com/blog/1552055
tag