一、使用TagSupport类案例解析

1.自定义Tag使用jdbc连接mysql数据库

1.1定义标签处理器类

package com.able.tag;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport; public class DBconnectionTag extends TagSupport {
private String driver;// 连接驱动
private String url;// 连接db地址
private String password;// 连接db密码
private String sql;// 查询sql
private String username;// 连接db用户名
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
@Override
public int doEndTag() throws JspException {
try {
Class.forName(this.driver);
conn = DriverManager.getConnection(this.url,this.username,this.password);
stmt = conn.createStatement();
rs = stmt.executeQuery(this.sql);
if (rs != null) {
while (rs.next()) {
pageContext.getOut().print(rs.getString("cname")+"<br/>");
}
}
return EVAL_PAGE;
} catch (Exception e) {
e.printStackTrace();
return SKIP_PAGE;
} finally {
try {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
} public String getDriver() {
return driver;
} public void setDriver(String driver) {
this.driver = driver;
} public String getUrl() {
return url;
} public void setUrl(String url) {
this.url = url;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public String getSql() {
return sql;
} public void setSql(String sql) {
this.sql = sql;
} public String getUsername() {
return username;
} public void setUsername(String username) {
this.username = username;
}
}

1.2 在tag.tld文件中添加tag标签

 <tag>
<name>DBconnectionTag</name><!-- 定义标签名 -->
<tag-class>com.able.tag.DBconnectionTag</tag-class>
<body-content>empty</body-content> <!-- 定义标签体为空 -->
<attribute>
<name>driver</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue><!-- 可以使用el表达式接收参数 -->
</attribute>
<attribute>
<name>url</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>username</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>password</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>sql</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

1.3 定义jsp,页面引入标签库,并定义标签

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<tm:DBconnectionTag url="jdbc:mysql://192.168.9.223:3306/test_2016" driver="com.mysql.jdbc.Driver" username="root" password="ablejava" sql="select * from course"/>
<br/>
<br>
</body>
</html>

2.forEach循环遍历输出集合

2.1 定义自定义标签处理器类

package com.able.tag;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport; public class ForEachTag extends TagSupport { private String var; private Iterator<?> iterator; public void setItem(Object item) {
if (item instanceof Map) {
Map items = (Map) item;
this.iterator = items.entrySet().iterator();
} else {
Collection<?> c = (Collection) item;
this.iterator = c.iterator();
}
} @Override
public int doStartTag() throws JspException {
if (this.process())
return EVAL_BODY_INCLUDE;
else
return EVAL_PAGE; } @Override
public int doAfterBody() throws JspException {
if (this.process()) {
return EVAL_BODY_AGAIN;
} else {
return EVAL_PAGE;
}
} private boolean process() { if (null != iterator && iterator.hasNext()) {
Object item = iterator.next();
pageContext.setAttribute(var, item);
return true;
} else {
return false;
}
} public String getVar() {
return var;
} public void setVar(String var) {
this.var = var;
}
}

2.3 在tld文件中定义标签

<tag>
<name>foreach</name>
<tag-class>com.able.tag.ForEachTag</tag-class>
<body-content>JSP</body-content> <attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>item</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<!-- <type>java.lang.Object</type> -->
<type>java.util.Collection</type>
</attribute>
</tag>

2.4 在jsp页面定义循环标签

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<%
List<String> list = new ArrayList<String>();
list.add("aa");
list.add("bb");
list.add("cc");
Map map = new HashMap();
map.put("1","a");
map.put("2","b");
map.put("3","c");
map.put("4","b");
%> <tm:foreach var="hi" item="<%=map %>">
<h1>${hi }</h1>
</tm:foreach>
<br/>
<br>
</body>
</html>

3.定义Iterator循环输出数组

3.1定义标签处理器类

package com.able.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport; public class IteratorTagDemo extends TagSupport {
private String var;
private String[] items; private int i =1;
@Override
public int doStartTag() throws JspException {
if (items != null && items.length>0) {
pageContext.setAttribute("name", items[0]);
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
}
} @Override
public int doAfterBody() throws JspException {
if (i<items.length) {
pageContext.setAttribute("name", items[i]);
i++;
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
} @Override
public int doEndTag() throws JspException {
// TODO Auto-generated method stub
return super.doEndTag();
}
public String getVar() {
return var;
} public void setVar(String var) {
this.var = var;
} public String[] getItems() {
return items;
} public void setItems(String[] items) {
this.items = items;
}
}

3.2 在.tld文件中定义标签

 <tag>
<name>IteratorTagDemo</name><!-- 定义标签名 -->
<tag-class>com.able.tag.IteratorTagDemo</tag-class>
<body-content>scriptless</body-content> <!-- 定义标签体为空 -->
<attribute>
<name>var</name>
<required>true</required>
</attribute>
<attribute>
<name>items</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

3.3在jsp页面定义Tag

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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> <%
String[] nbastar = {"jordan","kobar"};
pageContext.setAttribute("nbastar", nbastar);
%>
<tm:IteratorTagDemo items="${nbastar }" var="name">
${name }
</tm:IteratorTagDemo>
<br/>
<br>
</body>
</html>

4.自定义Tag实现防盗链

4.1自定义标签处理器类

package com.able.tag;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport; public class SkipPageOrEvalPageTag extends TagSupport { @Override
public int doEndTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String referer = request.getHeader("referer");
String url = "http://"+request.getServerName();
if (referer != null && referer.startsWith(url)) {
return EVAL_PAGE;
} else {
try {
pageContext.getOut().print("盗链");
} catch (IOException e) {
e.printStackTrace();
}
}
return SKIP_PAGE;
}
}

4.2在.tld文件中定义tag标记

<tag>
<name>SkipPageOrEvalPageTag</name><!-- 定义标签名 -->
<tag-class>com.able.tag.SkipPageOrEvalPageTag</tag-class>
<body-content>empty</body-content> <!-- 定义标签体为空 -->
</tag>

4.3定义访问连接的SkipPageOrEvalPageAccess.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<!-- 防盗链 -->
<a href="http://localhost/JSP_Tag_Demo/SkipPageOrEvalPage.jsp">防盗链</a>
<br/>
<br>
</body>
</html>

4.4定义访问成功后的SkipPageOrEvalPage.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<!-- 防盗链 -->
<tm:SkipPageOrEvalPageTag/>
<h1>SkipPageOrEvalPage标签处理学习</h1>
<br/>
<br>
</body>
</html>

二、使用SimpleTagSupport实现自定义Tag

1.继承SimpleTagSupport类实现循环输出集合或数组

1.1定义标签处理器类

package com.able.simpleTag;

import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport; public class foreachAll extends SimpleTagSupport {
private Object items;
private String var;
private Collection collection;
public void setItems(Object items) {
this.items = items;
if (items instanceof Collection) {//list set
collection=(Collection) items;
}
if (items instanceof Map) {
Map map=(Map) items;
collection =map.entrySet();//set
}
if (items instanceof Object[]) {
Object obj[]=(Object[]) items;
collection=Arrays.asList(obj);
}
if (items.getClass().isArray()) {
this.collection=new ArrayList();
int length=Array.getLength(items);
for (int i=0; i<length ; i++) {
Object value=Array.get(items, i);
this.collection.add(value);
}
}
}
public void setVar(String var) {
this.var = var;
}
@Override
public void doTag() throws JspException, IOException {
Iterator it=this.collection.iterator();
while (it.hasNext()) {
Object value=it.next();
this.getJspContext().setAttribute(var, value);
this.getJspBody().invoke(null); }
}
}

1.2定义.tld文件中添加标签

<tag>
<name>simpleforeachAll</name>
<tag-class>com.able.simpleTag.foreachAll</tag-class>
<body-content>scriptless</body-content>
<attribute>
<name>items</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

1.3定义jsp页面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<%
List<String> list = new ArrayList<String>();
list.add("aa");
list.add("bb");
list.add("cc");
Map map = new HashMap();
map.put("1","a");
map.put("2","b");
map.put("3","c");
map.put("4","b");
int arr[]={1,2,3,4,5};
request.setAttribute("arr", arr);
%> <br/>
<br>
<tm:simpleforeachAll var="i" items="${arr }">${i }</tm:simpleforeachAll>
</body>
</html>

2.使用SimpleTagSupport实现防盗链

2.1定义标签处理器类

package com.able.simpleTag;

import java.io.IOException;
import java.sql.Date; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.SkipPageException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
public class RefererTag extends SimpleTagSupport {
private String site;
private String page;
public void setSite(String site) {
this.site = site;
}
public void setPage(String page) {
this.page = page;
}
@Override
public void doTag() throws JspException, IOException {
PageContext pageContext =(PageContext) this.getJspContext();
HttpServletRequest httpServletRequest=(HttpServletRequest) pageContext.getRequest();
HttpServletResponse httpServletResponse=(HttpServletResponse) pageContext.getResponse();
//1.referer
String referer=httpServletRequest.getHeader("referer");
if (referer==null || !referer.startsWith(site)) {
if (page.startsWith(httpServletRequest.getContextPath())) {
httpServletResponse.sendRedirect(page);
return;
}else if (page.startsWith("/")) {
httpServletResponse.sendRedirect(httpServletRequest.getContextPath()+page);
}else{
httpServletResponse.sendRedirect(httpServletRequest.getContextPath()+"/"+page);
}
throw new SkipPageException();
}
} }

2.2 定义.tld文件

<tag>
<name>referer</name>
<tag-class>com.able.simpleTag.RefererTag</tag-class>
<body-content>empty</body-content>
<attribute>
<name>site</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>page</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

2.3定义refererAccess.jsp文件

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<!-- 防盗链 -->
<a href="http://localhost/JSP_Tag_Demo/Referer.jsp">防盗链</a>
<br/>
<br>
</body>
</html>

2.4定义访问页面referer.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<!-- 防盗链 -->
<tm:referer site="" page=""/>
<br/>
<br>
</body>
</html>

三、使用BodyTagSupport实现自定义Tag

1.继承BodyTagSupport实现简单数据输出

1.1定义标签处理器类

package com.able.bodyTag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport; public class BodyTagSupportTag extends BodyTagSupport {
private BodyContent bodyContent; @Override
public int doEndTag() throws JspException {
String content = bodyContent.getString();
System.out.println(content); String newStr = "www.cnblogs.com/izhongwei";
JspWriter jspWriter= bodyContent.getEnclosingWriter();
try {
jspWriter.write(newStr);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return EVAL_PAGE;
} public BodyContent getBodyContent() {
return bodyContent;
} public void setBodyContent(BodyContent bodyContent) {
this.bodyContent = bodyContent;
} }

1.2在.tld文件中定义标签

<tag>
<name>bodyTag</name><!-- 定义标签名 -->
<tag-class>com.able.bodyTag.BodyTagSupportTag</tag-class>
<body-content>scriptless</body-content> <!-- 定义标签体为空 -->
</tag>

1.3定义jsp文件

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- <%@taglib uri="http://www.able.com" prefix="tm" %> --%>
<%-- <%@ taglib prefix="tm" uri="/WEB-INF/tlds/online.tld" %> --%>
<%@taglib prefix="tm" uri="/WEB-INF/tag.tld" %>
<!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>
<tm:bodyTag>
hello
</tm:bodyTag>
<br/>
<br>
</body>
</html>

源码下载地址:https://github.com/ablejava/jsp-Tag

git克隆地址:https://github.com/ablejava/jsp-Tag.git  

jsp中自定义Taglib案例的更多相关文章

  1. jsp中的taglib

    JSP中使用Taglib 标准的JSP标记可以调用JavaBeans组件或者执行客户的请求,这大大降低了JSP开发的复杂度和维护量.JSP技术也允许你自定义的taglib,其实换句话说,taglib可 ...

  2. 自定义JSP中的Taglib标签之四自定义标签中的Function函数

    转自http://www.cnblogs.com/edwardlauxh/archive/2010/05/19/1918589.html 之前例子已经写好了,由于时间关系一直没有发布,这次带来的是关于 ...

  3. jsp中 自定义 tag的几种方式

    在jsp文件中,可以引用tag和tld文件. 1.对于tag文件,使用tagdir引用(这个直接是引用的后缀tag文件的jsp文件) <%@ taglib prefix="ui&quo ...

  4. [置顶] JSP中使用taglib出错终极解决办法

    jsp中 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c ...

  5. JSP中使用Taglib

    http://blog.163.com/jany_1016/blog/static/4604400620091112114127341/ http://blog.csdn.net/yuebinghao ...

  6. jsp 中获取自定义变量

    首先确定El表达式的查找范围: 依次从Page.Request.Session.Application 中的 attribute属性中查找. <% String basePath = reque ...

  7. JSP 中的 tag 文件

    在jsp文件中,可以引用 tag 和tld 文件,本文主要针对 tag 对于tag 文件 1)将此类文件放在 WEB-INF 下,比如 /WEB-INF/tags,tags 是目录,其下可以有多个.t ...

  8. jsp中的JSTL与EL表达式用法

    JSTL (JSP Standard Tag Library ,JSP标准标签库) JSTL标签库分为5类:JSTL核心标签库.JSTL函数标签库.数据库标签库.I18N格式化标签库.XML标签库. ...

  9. jsp中c:forEach使用

    首先需要在jsp中引入<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> ...

随机推荐

  1. 我也要学iOS逆向工程--函数

    大家好,这篇我开始学习函数了.先学 C 函数,然后再 OC 的吧.OC 应该复杂点的吧. 然后看看汇编情况哦! 学习函数呢,肯定要弄清楚几个事情. 1.跳转地址. 2.返回地址 3.参数 4.函数获取 ...

  2. Spark源码系列(四)图解作业生命周期

    这一章我们探索了Spark作业的运行过程,但是没把整个过程描绘出来,好,跟着我走吧,let you know! 我们先回顾一下这个图,Driver Program是我们写的那个程序,它的核心是Spar ...

  3. 10个你必须掌握的超酷VI命令技巧

    摘要:大部分Linux开发者对vi命令相当熟悉,可是遗憾的是,大部分开发者都只能掌握一些最常用的Linux vi命令,下面介绍的10个vi命令虽然很多不为人知,但是在实际应用中又能让你大大提高效率. ...

  4. Etl之HiveSql调优(union all)

    相信在Etl的过程中不可避免的实用union all来拼装数据,那么这就涉及到是否并行处理的问题了. 在hive中是否适用并行map,可以通过参数来设定: set hive.exec.parallel ...

  5. MS SQL的存储过程

    -- ============================================= -- Author: -- Create date: 2016-07-01 -- Descriptio ...

  6. uniGUI试用笔记(十五)通过URL控制参数

    通过URL代入参数,在代码中读取,如: http://localhost:8501/?ServerPort=212&&ServerIP=192.168.31.12 在代码中可以通过: ...

  7. C 语言函数参数只能传指针,不能传数组

    今天被要求编写一个C/C++冒泡算法的程序,心想这还不是手到擒来的事儿,虽然最近都是用Javascript程序,很少写C/C++程序,但是好歹也用过那么多年的C语言: 首先想的是怎么让自己的代码看上去 ...

  8. 让我们一起Go(九)

    前言: 又好久么更新了,无奈公司项目多,自己又接了私活,于是时间更不够了......不过我是不会让它流产的,坚持! 一.Go语言中的函数 终于轮到函数了,其实也没有什么好说的,无非就是一个语法问题,c ...

  9. android手势创建及识别

    使用一些浏览器或者输入法应用时会有一些手势操作,还可以自定义手势.这些神奇的操作是怎么做的呢?这一篇重点记录手势的识别和创建.这篇的内容使用到的是android.gesture包,具体的例子参考的是S ...

  10. 没有找到cxcore100.dll,因此这个应用程序未能启动,重新安装应用程序可能会修复此问题

    第一种情况: 出现这个问题多数是因为“环境变量PATH”未设置,虽然你可能在安装的过程中勾选了Add <...>\OpenCV\bin to the system PATH项!安装Open ...