自定义函数库
来源:互联网 发布:淘宝付款方式怎么设置 编辑:程序博客网 时间:2024/05/27 01:14
* 写一个java类,类中可以定义0~N个方法,但必须是static,而且有返回值的! * 在WEB-INF目录下创建一个tld文件 <function> <name>fun</name> <function-class>cn.itcast.fn.MyFunction</function-class> <function-signature>java.lang.String fun()</function-signature> </function> * 在jsp页面中导入标签库 <%@ taglib prefix="it" uri="/WEB-INF/tlds/itcast.tld" %> * 在jsp页面中使用自定义的函数:${it:fun() }
1. 编写类类中只能有public static的方法,并且一定要有返回值public class ItcastFuncations {public static String test() {return "自定义EL函数库测试";}}2. 部署文件/WEB-INF/itcast.tld<?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>itcast</short-name> <uri>http://www.itcast.cn/jsp/functions</uri> <function> <name>test</name> <function-class>cn.itcast.el.funcations.ItcastFuncations</function-class> <function-signature>String test()</function-signature> </function></taglib>3. 在JSP中使用自定义<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib prefix="itcast" uri="/WEB-INF/itcast.tld" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <body> <h1>${itcast:test() }</h1> </body></html>
阅读全文
1 0
- 自定义函数库
- 自定义函数库
- jstl函数库及自定义函数库
- jstl函数库及自定义函数库
- ASP自定义函数库
- maxima之自定义函数库
- VC++ 自定义函数库
- jstl 自定义函数库
- JSTL 自定义函数库
- 高手的自定义函数库
- JSTL 自定义函数库
- 7 PHP 自定义函数库
- 自定义的js函数库
- EL和自定义函数库
- ThinkPHP3.2.3自定义函数库
- 自定义EL函数库
- JavaScript 自定义函数库
- laravel 自定义函数库
- UVA11729 贪心
- 171004 逆向-PE头知识
- Mac版R语言入门(四)在R中加载多个包的实用技巧
- CSS 3 Keyframes
- 编程开发流程
- 自定义函数库
- 关于正确使用PHP的in_array数组
- eclipse自动生成作者、日期注释等功能设置
- wxWidgets无标题栏窗口的拖动
- Makefile初识
- Latex字体设置
- FTPrep, 99 Recover Binary Search Tree. TODO
- hahaha
- 使用ffmpeg接口将YUV编码封装为文件