2011-08-13 19 views
0

我打算創建自己的taglib,並將jsp變量作爲屬性值傳遞給taglib。JSP:使用表達式作爲tablib屬性的值

<%@標籤庫URI = 「/ WEB-INF/taglib.tld」 前綴= 「自定義」 %>

<%String myFilter =....; %> 
<custom:printAllPeople filter="<%=myFilter%>" > 

</custom:printAllPeople> 

在TLD:

<taglib> 
    <tlibversion>1.0</tlibversion> 
    <jspversion>1.1</jspversion>  
    <tag> 
     <name>printAllPeople</name> 
     <tagclass>jb.taglib.FilterPersonTagLib</tagclass>  
     <attribute> 
      <name>filter</name> 
      <required>true</required>   
     </attribute>     
     <info>print all people</info> 
    </tag> 
</taglib> 

,我goto: org.apache.jasper.JasperException:/filterTagLib.jsp(行:23,列:1)根據標記文件中的TLD或屬性指令,屬性過濾器不接受任何表達式

我如何使用表達式作爲屬性值?

回答

1

你需要使用rtexprvalue在你的TLD屬性:

<attribute> 
    <name>filter</name> 
    <required>true</required> 
    <rtexprvalue>true</rtexprvalue> 
</attribute>