• el自定义函数库


    举一个编码问题的例子:

     

     

    /**

     * 自定义El函数库

     *@author Administrator

     *

     */

    public class FunctionsEl {

     

           publicstatic String decode(String str) throws UnsupportedEncodingException{

                  if(StringUtils.isNotBlank(str)){

                         returnURLDecoder.decode(str,"utf-8");

                  }

                  return"";

           }

    }

     

    写一个tld文件

     

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

     

    <taglibxmlns="http://java.sun.com/xml/ns/j2ee"

     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

     xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"

     version="2.0">

     

     <description>MYJSTL 1.0 functions library</description>

     <display-name>MYJSTL functions</display-name>

     <tlib-version>1.0</tlib-version>

     <short-name>myfn</short-name>

     <uri>http://www.xxx.cn/jsp/jstl/functions</uri>

     

     <function>

       <name>decode</name>

        <!--此处是定义类的路径-->

       <function-class>cn.xxx.crm.functions.FunctionsEl</function-class>

         <!--此处是定义类的返回值类型和传入参数类型-->

       <function-signature>java.lang.String decode(java.lang.String)</function-signature>

     </function>

    </taglib>

     

    在jsp页面中的使用:

    <!--首先要引入-->

    <%@ tagliburi="http://www.xxx.cn/jsp/jstl/functions" prefix="myfn"%>

     

    ${myfn:decode(string)}搞定

     

    转载:http://www.cnblogs.com/jqyp/archive/2010/09/03/1816501.html

  • 相关阅读:
    实验三:Linux进程管理(HDU)
    ORA-25153错误及解决办法
    Python中的next()iter()函数详解
    python基础_格式化输出(%用法和format用法)(转载)
    DataTable ---导出Excel
    gridview-
    Web-Web/Json的请求与返回
    Sql-事务
    Windows-远程桌面
    Dev-GridView-对于gridview的列值的合计
  • 原文地址:https://www.cnblogs.com/summer520/p/2964286.html
Copyright © 2020-2023  润新知