这是在单个tld文件中,即在自定义标记中编写多个属性和多个函数的适当方式。
下面是代码中的标签:
<tag>
<name>cardwidgettags</name>
<tag-class>com.sciformix.sciportal.apps.dap.CardWidget</tag-class>
<body-content>empty</body-content>
<attribute>
<name>title</name>
<required>true</required>
</attribute>
<attribute>
<name>link</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>icon</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<function>
<name>addLineItem</name>
<function-class>.dap.CardWidget</function-class>
<rtexprvalue>true</rtexprvalue>
<function-signature>void addLineItem(java.lang.String, java.lang.String, java.lang.String)</function-signature>
</function>
</taglib>如何从jsp页面一次性调用它。
谢谢
发布于 2019-10-01 03:41:06
在您的tld文件中,您可以执行如下操作:
functions.tld
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
<tlib-version>1.0</tlib-version>
<short-name>functions</short-name>
<uri>http://anyurl.com/myfunctions</uri> <!-- define url to access functions from jsp file -->
<function>
<name>functionOne</name> <!-- function name -->
<function-class>com.mypackage.MyUtilClass</function-class> <!-- full path to your class where define function -->
<function-signature>void functionOne(java.lang.Integer, java.lang.Integer, java.lang.Integer)</function-signature>
</function>
<function>
<name>functionTwo</name> <!-- function name -->
<function-class>com.mypackage.MyUtilClass</function-class> <!-- full path to your class where define function -->
<function-signature>void functionTwo(java.lang.String, java.lang.String, java.lang.String)</function-signature>
</function>
</taglib>myjsp.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="myfnc" uri="http://anyurl.com/myfunctions" %> <!-- url is defined above -->
...
${myfnc:functionTwo("str1","str2", "str3")}
${myfnc:functionOnw(1, 2, 3)}https://stackoverflow.com/questions/58129102
复制相似问题