zoukankan      html  css  js  c++  java
  • 自定义EL函数:小写转大写

    1,定义java静态方法,FunctionDemo,有小写转大写的功能

    package com.itheima.domain;
    
    public class FunctionDemo {
    	public static String toUpperCase(String string){
    		return string.toUpperCase();
    	}
    }
    

     2,编辑xml文件,扩展名为tld

    需要指定类的详细名称,带包名,方法的详细信息,返回值+方法名+参数,和访问路径uri,在页面中导入这个uri才能使用,前缀

    <?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">
      <tlib-version>1.0</tlib-version>
      <short-name>itheima</short-name>
      <uri>http://www.heima.com/jsp/myfun</uri>
    
      <function>
        <description>
          toUpperCase
        </description>
        <name>toUpperCase</name>
        <function-class>com.itheima.domain.FunctionDemo</function-class>
        <function-signature>java.lang.String toUpperCase(java.lang.String)</function-signature>
        <example>
          <itheima:toUpperCase("aavvavb")>
        </example>
      </function>
    </taglib>
    

     3在页面中使用,需要用taglib标签,指定uri和前缀

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
     <%@taglib uri="http://www.heima.com/jsp/myfun" prefix="itheima" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    </head>
    <body>
     ${itheima:toUpperCase("adsafjka") }
    </body>
    </html>
    
  • 相关阅读:
    [转]VMware-Transport(VMDB) error -44:Message.The VMware Authorization Service is not running解决方案
    [转]DNS服务器原理详解与Centos6.x下搭建DNS服务器
    [转]美国最大婚恋交友网站eHarmony的机器学习实践
    [转]Algolia的分布式搜索网络架构
    预测建模、监督机器学习和模式分类概览
    Java正则表达式
    Ajax入门
    JSON入门
    JSTL与EL表达式
    Servlet与JSP进阶
  • 原文地址:https://www.cnblogs.com/lzzhuany/p/4719226.html
Copyright © 2011-2022 走看看