易截截图软件、单文件、免安装、纯绿色、仅160KB

jsp自定义标签(tag)开发

1 标记处理程序类
处理类继承TagSupport类并重载doStartTag()方法,
       在该方法中使用out.print();输出需要的数据到使用本标签的jsp页面
package cn.xxx;
public class DateTag extends TagSupport {
private static final long serialVersionUID = 1L;
public int doStartTag() throws javax.servlet.jsp.JspException {
JspWriter out;
try {
out = pageContext.getOut();
out.print("hello你好" + new Date());
} catch (IOException ioe) {
throw new JspException("I/O Error : " + ioe.getMessage());
}
return Tag.SKIP_BODY;//return 0;
}

2 创建使用标签类的创TLD文件
(可以从struts中的标签库中的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
web-jsptaglibrary_2_0.xsd" verson="2.0">

<tlib-version>1.0</tlib-version>
<jspversion>1.1</jspversion>

<info>A simple tag library</info>
<tag>
<name>displayDate</name>
<tagclass>cn.eecn.DateTag</tagclass>
<bodycontent>empty</bodycontent>
<info>Display Date</info>
</tag>
</taglib> 
3 导入标签库
    * 方法1
          在web.xml文件中先静态导入tld文件,再jsp中用别名导入标签
web.xml:
<taglib>
<taglib-uri>myTags</taglib-uri>
<taglib-location>/WEB-INF/lib/DateTagLib.tld</taglib-location>
</taglib> 
jsp:
<%@ taglib uri="myTags" prefix="abc" %> 
* 方法2:
        在jsp页面中直接使用动态导入tld文件
<%@ taglib uri="/WEB-INF/lib/DateTagLib.tld" prefix="abc" %> 
4 在页面中使用标签
    jsp
<abc:displayDate /> 
引用参考:http://blog.myspace.cn/e/406226695.htm


相关文档:

jsp学习笔记5

JSP2.0中的表达式语言(EL表达式)
EL语法
EL的语法很简单,他最大的特点就是使用上很方便
例:
${sessionScope.user.sex}
所有EL都是以 ${ 为起始、以} 为结尾的。
上述EL范例的意思是:从Session取得用户的性别。如果使用之前JSP代码的写法如下:
<%
  User user = (User)session.getAttribute("user");
& ......

纯JSP分页代码之Mysql

//运行图:
//连接字符串
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
Class.forName(driverName).newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
//每页显示记录数
int PageSize ......

在JSP中配置FCKeditor 2.6.4

1.FCKeditor 介绍
FCKeditor 这个开源的HTML 文本编辑器可以让web 程序拥有如MS Word 这样强大的编辑功能,.FCKeditor 支持当前流行的浏览器。
2.准备工作:
环境:winddows XP、tomcat6.0、JDK1.6
下载:
1):FCKeditor_2.6.4.zip
地址:http://nchc.dl.sourceforge.net/sourceforge/fckeditor/FCKeditor_2.6.4.zip ......

jsp页面div应用

<%@ page contentType="text/html;charset=GBK"%>
<div id="divDisable" style="display: none;width:expression(document.body.offsetWidth); height:100%; z-index: 1000; position: absolute;left: 0px; top: 0px;filter:alpha(opacity=50); background-color:White">
</div>
<div id="divWaiti ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号