=============================================================================================================== ================
Step1: Create a new Java class
One thing to note about this class is that the method must be static. This is a good understanding, the function of the El Call, can be considered a tool class, there is no need to instantiate before calling. The ideal method is to complete the static method, directly through the class to invoke it.
--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ----------
Package Net.thecatcher.ELdemo;
Public class ELDemo1 {
Public Static String SayHello (string name) {
return "Hello" + name;
}
}
=============================================================================================================== ================
Step2: TLD files that need to be edited
The eclipse that I used, the way I found it, was built like this, but it didn't seem so good. I copied the following code directly, and then modify ...
NEW----> XML----> XML File----> Input test.tld
----> Create XML file from a DTD file----> Select XML Catalog entry
---->-//sun Microsystems, inc.//dtd JSP Tag Library 1.2//en
----> Finish
--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ----------
<?xmlversion= "1.0"encoding="UTF-8"?>
<taglib version="2.0" xmlns="Http://java.sun.com/xml/ns/j2ee "
xmlns:xsi="Http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0. XSD ">
<tlib-version>1.0</tlib-version>
<short-name>myfn</short-name>
<uri>http://www.thecatcher/myfn</uri>
<function>
<name>sayHi</name>
<function-class>net.thecatcher.ELdemo.ELDemo1</function-class>
<function-signature>java.lang.string SayHello (java.lang.String) </function-signature>
</function>
</taglib>
=============================================================================================================== ================
Step3: The JSP file is referenced by Taglib
--------------------------------------------------------------------------------------------------------------- ----------------
<%@ page language="java" contenttype="text/html; Charset=utf-8 "
pageencoding="UTF-8"%>
<%@ taglib uri="HTTP://WWW.THECATCHER/MYFN" prefix=" myfn"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv="Content-type" content= "text/html; Charset=utf-8 ">
<title>insert title here</title>
<body>
${myfn:sayhi ("Meimei")}
</body>
Eclipse New Custom El function