El expression-UDF)

Source: Internet
Author: User

you can see an interesting application, Turn it off, huh, huh !!

1. definition class myfunction ( note: method must be Public static)

Package Com. tgb. jstl;


/**  
 
* UDF implementation class in the jstl label

*
 
  */

Public Class Myfunctions {

Public Static String sayhello (string name ){

Return "Hello" + name;

}

}

2.ProvideTLDDescription file,This file can be placed inWEB-INFOr under its Directory.

<? XML version = "1.0" encoding = "UTF-8" ?>

< Taglib 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"
Version = "2.0" >
< Description > Myfunctions Library </ Description >
< Display-name > Jstl Functions </ Display-name >
< Tlib-version > 1.1 </ Tlib-version >

<! -- The so-called "abbreviation" here can be written at will -->
< Short-name > MFN </ Short-name >
<! -- The URI here can be written at will -->
< Uri > Http://www.tgb.com/functions </ Uri >

< Function >
<! -- The name can be written as needed. -->
< Name > Say </ Name >
<! -- It is most important to specify the class location and some important information about the class method. -->
< Function-class > Com. tgb. jstl. myfunctions </ Function-class >
< Function-Signature > Java. Lang. String sayhello (Java. Lang. String) </ Function-Signature >
</ Function >

</ Taglib >

3.InJSPUseTaglibIntroduce function library

< % @ Taglib Uri = Http://www.tgb.com/functions"   Prefix = "MFN" % >  

4. in El + colon + use function names

call functions related to the function library, El Expression.

$ {MFN: say ("Tom")} <--- "Tom" can be changed to an El expression

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.