1.利用EasyUi制作自己的TLD-环境搭建

要制作属于自己的tld,第一步就要搭建tld的环境,这篇文章就记录一下自己详细的搭建步骤。

1.新建一个web工程

2.建tld文件

注意:tld文件只能在WEB-INF根目录或者其子目录下,不能在别的目录下

3.web.xml配置tld的引用(此步骤可以省略)

 

4.书写第一个标签

具体的配置如图:

5.书写处理类

package com.ui;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class TextInputTag extends TagSupport{

	private static final long serialVersionUID = 1L;
	private String required;
	@Override
	public int doStartTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			StringBuffer sqlBF = new StringBuffer();
			sqlBF.setLength(0);
			sqlBF.append("<input type = \"text\"></input>");
			out.print(sqlBF.toString());
		} catch (IOException e) {
			throw new JspException("标签往前台写数据时异常");
		}catch(Exception e){
			throw new JspException("其他异常");
		}
		return SKIP_BODY;
	}

	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}

	public String getRequired() {
		return required;
	}

	public void setRequired(String required) {
		this.required = required;
	}
	
	
}

  6.写测试的页面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="zl" uri="EasyUITag"  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  <body>
  	<zl:textinput required="true"></zl:textinput>
  </body>
</html>

  7.测试

成功了。

posted on 2015-03-19 20:09  大师之路  阅读(1262)  评论(0)    收藏  举报