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£¨java server page£©
JSPÊÇ·þÎñÆ÷¶ËÔËÐеÄÒ³Ãæ£¬JSP±¾Ê¾ÍÊÇÒ»¸öÎĵµ£¬Ëû²»½ö¿ÉÒÔ°üº¬¾²Ì¬µÄHTML´úÂ룬Ҳ¿ÉÒÔ°üº¬¶¯Ì¬µÄJAVA´úÂ룬·þÎñÆ÷ÈÝÆ÷¿ÉÒÔ½«JSPת»»³ÉServlet·¢²¼£¬²¢½ÓÊÜÇëÇó¡£
JspÎļþÖ»Ðè·ÅÔÚÓ¦ÓÃÎļþϾͿÉÒÔÁË¡£
JSPÀý×Ó£º
<html>
<head& ......
(1)include ÔÚJSP±àÒë³ÉJavaÀàÎļþʱ£¬ÏȽ«includeÎļþÄÚÈݺϲ¢ºó£¬ÔÙ½øÐбàÒë
(2)jsp:include ÔËÐÐʱºÏ²¢,»á½«ÔËÐÐʱµÄ½á¹û°üº¬½øÀ´
(3)c:import ÔËÐÐʱºÏ²¢,»á½«ÔËÐÐʱµÄ½á¹û°üº¬½øÀ´
Òò´Ë£¬
£¨1£©ÀûÓÃinclude°üº¬µÄÒ³ÃæÖÐÈç¹û°üº¬Á˺ÍÔÒ ......
//ÔËÐÐͼ:
//Á¬½Ó×Ö·û´®
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 ......
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 ......
Action´úÂë
package com.zxc.action;import java.net.URLEncoder;public class XiaoZAction {
private String username; public String getUsername() { return username; }
public String execute() throws Exception{
username = URLEncoder.encode("ÖÜС´¨", "utf-8"); return "success"; }}
struts.x ......