自定义EL表达式
来源:互联网 发布:java main方法意思 编辑:程序博客网 时间:2024/05/21 12:39
1、首先编写EL处理类 预定义为表达式的方法必须为 公共静态
package com.hkrt.demo;public class Util {public static int length(){return 100;}}2、定义util.tld /WEB-INF/util.tld
<?xml version="1.0" encoding="UTF-8"?><taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3,org/2001/XMLSchema-instancce"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/cml/ns/javaee/web-jsptaglibrary_2_1.xsd"><tlib-version>1.0</tlib-version><short-name>自定义EL</short-name><uri>http://www.icardpay.com/util</uri><function><description>Length</description><name>length</name><function-class>com.hkrt.demo.Util</function-class><function-signature>int length()</function-signature></function></taglib>
3、页面调用自定义EL
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%@taglib prefix="util" uri="/WEB-INF/util.tld"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--> </head> <body> 后面会输出自定义表达式的返回值 ${ util:length() }<br> </body></html>
- 自定义EL表达式方法
- 自定义EL表达式
- 自定义EL表达式
- EL表达式-自定义函数
- 自定义EL表达式
- 自定义EL表达式方法
- 自定义EL表达式方法
- EL表达式-自定义函数
- 自定义el表达式方法
- 自定义EL表达式
- EL表达式-自定义函数
- 自定义EL表达式方法
- EL表达式-自定义函数
- 自定义el表达式函数
- EL表达式-自定义函数
- El表达式 自定义标签 El函数区别
- 自定义EL表达式方法详解
- EL 表达式中自定义函数
- chromium load url
- java文件读写
- 挑战编程: 最长有效括号的长度
- 本地nexus的使用
- 二层交换机、三层交换机和路由器的基本工作原理和三者之间的主要区别
- 自定义EL表达式
- c语言字符串函数详解
- dup and dup2的剖析
- unity基础开发----引用第三方DLL,解析JSON
- CORBA异常原因定位
- Web必备:30款超棒JS类库和工具分享(arvin--推荐)
- Win7中IIS和ASP的安装、配置和使用
- 关于initrd的一些整理
- ios中的coredata的使用