一、使用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. GitHub上排名前100的iOS开源库介绍(来自github)

    主要对当前 GitHub 排名前 100 的项目做一个简单的简介,方便初学者快速了解到当前 Objective-C 在 GitHub 的情况. 若有任何疑问可通过微博@李锦发联系我 项目名称 项目信息 ...

  2. js后退一直停留在当前页面或者禁止后退

    //禁用后退按钮 function stopHistoryGo() { //禁用回退 window.location.hash="no-back-button"; window.l ...

  3. 牢骚与javascript中的this

    最近在看关于拖延症的一本书<拖拉一点也无妨>,后面得出结论是自己写博客大部分处于两种状态,心情很好和心情很不好的时候.因为正常状态下感觉写博客吧,是件很麻烦的事情,不如去看看电影看看漫画啥 ...

  4. Oracle数据库入门——如何根据物化视图日志快速刷新物化视图

    Oracle物化视图的快速刷新机制是通过物化视图日志完成的.Oracle如何通过一个物化视图日志就可以支持多个物化视图的快速刷新呢,本文简单的描述一下刷新的原理. 首先,看一下物化视图的结构:SQL& ...

  5. 高效的INSERT INTO SELECT和SELECT INTO

    1.INSERT INTO SELECT,目标表必须存在,才可批量插入 INSERT INTO 目标表Table(field1,field2,field2,...) SELECT value1,val ...

  6. 使用SharePoint Designer定制开发专家库系统实例!

    将近大半年都没有更新博客了,趁这段时间不忙,后续会继续分享一些技术和实际应用.对于Sharepoint的定制开发有很多种方式,对于一般的应用系统,可以使用Sharepoint本身自带的功能,如列表作为 ...

  7. 【weka应用技术与实践】过滤器

    weka中的过滤器主要用于数据预处理阶段对数据集的各种操作. 今天简单地使用一下过滤器: 首先打开一个自带数据集weather.numeric.arff,这是一个关于通过天气条件,气温以及风力等因素来 ...

  8. 用CentOS 7打造合适的科研环境 :zhuan

    这篇博文记录了我用CentOS 7搭建地震学科研环境的过程,供我个人在未来重装系统时参考.对于其他地震学科研人员,也许有借鉴意义. 阅读须知: 本文适用于个人电脑,不适用于服务器: 不推荐刚接触Lin ...

  9. 谷歌正式发布Google APIs Client Library for .NET

    好消息,特大好消息! 英文原文:Google API library for .NET paves the way for Google services on Windows phone 本月 17 ...

  10. Linux高级编程--07.进程间通信

    每个进程各自有不同的用户地址空间,进程之间要交换数据必须通过在内核中开辟缓冲区,从而实现数据共享. 管道 管道是一种最基本的IPC机制,由pipe函数创建: int pipe(int filedes[ ...