zoukankan      html  css  js  c++  java
  • 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)}搞定

  • 相关阅读:
    Flex 布局
    前端跨域之jsonp
    vs code 自定义代码片段
    vue中使用axios进行http通信
    Table边框合并
    getElementsBy 系列方法相比querySelector系列的区别
    vue中watch简单使用
    png图标任意赋色
    pc端与移动端适配解决方案之rem
    Express post请求无法解析参数的原因
  • 原文地址:https://www.cnblogs.com/jqyp/p/1816501.html
Copyright © 2011-2022 走看看