Eclipse New Custom El function

Source: Internet
Author: User
Tags tld

=============================================================================================================== ================

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.