EL表达式(2)
来源:互联网 发布:simple antnotes mac 编辑:程序博客网 时间:2024/06/05 16:05
1、访问作用域范围的隐含对象
pageScope,requestScope,sessionScope,applicationScope
2、定义使用EL函数
建个.java,方法为静态方法、在web-inf中创建.tld然后就可以调用静态方法了
java
package com.gaint.el;
public class KindMethod {
//字符串翻转
public static String reverse(String text){
System.out.println("-----------字符串翻转text-------"+text);
String result = new StringBuffer(text).reverse().toString();
System.out.println("-----------字符串翻转-------"+result);
return result;
}
//转化为大写字母
public static String cape(String text){
System.out.println("-----------字符串翻转转化为大写字母text-------"+text);
String result = new String(text).toUpperCase();
System.out.println("-----------字符串翻转转化为大写字母-------"+result);
return result;
}
}
.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"> <description>library</description> <display-name>functions</display-name> <tlib-version>1.1</tlib-version> <short-name>fn</short-name> <function> <description>reverse</description> <name>reverse</name> <function-class>com.gaint.el.KindMethod</function-class> <function-signature>java.lang.String reverse( java.lang.String )</function-signature> </function> <function> <description>cape</description> <name>cape</name> <function-class>com.gaint.el.KindMethod</function-class> <function-signature>java.lang.String cape( java.lang.String )</function-signature> </function></taglib>
index
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@ taglib prefix="fn" uri="/WEB-INF/funcation.tld" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%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"> </head> <body> <form action="index.jsp"> <table> <tr> <td> <input type="text" name="foo" value="${param.foo}"></input> <input type="submit" name="Sumit" value="提交"></input> </td> </tr> </table> </form> <table> <tr> <td>说明</td> <td>输出结果</td> </tr> <td>将输入内容翻转输出</td> <td>${fn:reverse(param.foo)}</td> <tr> </tr> <td>将输入内容转化为大写字母</td> <td>${fn:cape(param.foo)}</td> <tr> </tr> </table> escapeXML属性为true是: <c:out value="水平标记<hr>" escapeXml="true"></c:out> <br> escapeXML属性为false是: <c:out value="水平标记<hr>" escapeXml="false"></c:out> </body></html>
0 0
- EL表达式(2)
- 第六章EL和JSTL 1-el表达式(2)
- JSP(2)EL表达式入门
- EL表达式2
- EL表达式不起作用2。
- [综合]EL表达式(2)
- EL表达式详解2
- el表达式-2
- EL表达式2
- EL表达式 (详解)
- EL表达式 (详解)
- EL表达式 (转)
- 表达式语言(EL)
- EL表达式(二)
- EL表达式 (详解)
- EL表达式 (详解)
- EL表达式 (详解)
- EL表达式 (详解)
- java 动态代理
- iOS开发长文--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总
- Flume安装
- JAVA菜鸟入门篇 - Calendar日历类和GregorianCalendar公历类 (二十八)
- [LeetCode]162.Find Peak Element
- EL表达式(2)
- session 怎么看
- Remove Duplicates from Sorted List II
- JAVA编程思想学习笔记十一:持有对象
- C#类静态构造函数
- jQuery中eq和get的区别
- poj 2387 Til the Cows Come Home(kuangbin带你飞 专题四:最短路)
- 一个人如何快速赚到一百万?
- php四种参数传递方法