JSP/EL Syntax/EL Function/Make my EL Function

JSP/EL Syntax/EL Function/Make my EL Function

Write static method. you want

In this case, I make getting String and Return String method.

Create static method.

Hoge.java
public class Hoge{
    public static String aaa(String bbb){		
        return bbb + "hoge";		
    }
}

Make taglib file

Make taglib file. Writing called name, target class and target method name.

hoge.tld
<?xml version="1.0" ?>
<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 web-jsptaglibrary_2_0.xsd" version="2.0">
<tlib-version>2.0</tlib-version>
<function>
    <name>hoge</name>
    <function-class>jp.co.hogehoge.util.Hoge</function-class>
    <function-signature>java.lang.String aaa(java.lang.String)</function-signature>
</function>
</taglib>

Use taglib

Import the taglib file in JSP file.

<%@taglib uri='/WEB-INF/tlds/hoge.tld' prefix='hhh' %>

prefix is called name in JSP file.

Tags

java/jsp/el_syntax/el_function/make_my_el_function_en.txt · 最終更新: 2018-03-30 18:00 by ore