Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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¹ýÂËÆ÷µÄÍêÕûÀý×Ó

ÔÚ±¾ÆªÎÄÕÂÖн«Ê¹ÓùýÂËÆ÷½øÐбàÂëת»»¡¢µÇ½ÑéÖ¤¡¢·ÀÕ¾ÍâÌá½»µÄ¹ý³Ì£¬ÎªÁËÑÝʾ£¬ÎҰѱàÂëת»»·ÅÔÚÒ»¸öfilterÖУ¬µÇ½ÑéÖ¤ºÍ·ÀÕ¾ÍâÌá½»·ÅÔÚÁíÒ»¸öfilterÖУ¬Á½¸öfilter½øÐд®Áª¹¤×÷¡£
1¡¢ÎªÁËÑÝʾ£¬ÏÈÖÆ×÷ÕâÁ½¸öfilter
//Õâ¸öfilterÊÇΪÁË×ö±àÂëת»»£¬Ö»Òª·ÃÎÊ.jspÍøÒ³¶¼Òª¹¦¹ýÕâ¸öfilter
/**ÀàÃû£ºfilter.Encoding
*×÷ ......

jspѧϰ±Ê¼Ç2

JSPµÄ×¢ÊÍ
<%--........--%>
JSPÖ¸ÁîºÍJSP¶¯×÷£¨±ê×¼µÄJSP±êÇ©£©
JSPÖ¸ÁîµÄÓï·¨
<%@... ....%>
<%@include file="...."%> °üº¬Ö¸Á°üº¬Ö¸Áî»á½«Òª°üº¬µÄÎļþ´úÂëÔ­ÑùÊä³öµ½±¾Ò³Ã棨ÔÚ·­Òëʱ°Ñ°üº¬ÎļþµÄÄÚÈÝÒýÈë²¢ºÏ²¢£©£¬²»½øÐз­Ò룬fileÊôÐÔÖÆ¶¨Òª°üº¬µÄÎļþµÄÃû×Ö£¨×¢ÒâÒª°üº¬µÄÎļþµÄ·¾¶£©£ ......

jspµÄÄÚÖöÔÏó¡¢¹¦ÄÜÒÔ¼°Ö÷Òª·½·¨

jspµÄÄÚÖöÔÏó¡¢¹¦ÄÜÒÔ¼°Ö÷Òª·½·¨
JspÄÚÖöÔÏó ¹¦ÄÜ Ö÷Òª·½·¨
out  Ïò¿Í»§¶ËÊä³öÊý¾Ý print() println() flush() clear() isAutoFlush() getBufferSize()   close() …………
request Ïò¿Í»§¶ËÇëÇóÊý¾Ý getAttributeNames() getCookies() getParameter() getParameterValues() ......

jspÁ¬½Ómysql¶ÔÊý¾Ý¿â½øÐвÙ×÷ÂÒÂëµÄ½â¾ö


Èç¹ûjsp²åÈëmysqlÊý¾Ý¿â³öÏÖÂÒÂ룬mysqlÊý¾Ý¿â°²×°Ê±±àÂëÉèΪutf8£¬ÔÚÖ´ÐвåÈëÓï¾äµÄÇ°Ãæ£¨½ô°¤×ÅÖ´ÐÐÓï¾ä£©Ìí¼ÓתÂëÓï¾ä£ºString na="";
                  try{
          &nbs ......

jspµÄ°Ë¸öÒþº¬¶ÔÏó

Ò»¡¢page ¶ÔÏó
    page¶ÔÏó´ú±íJSP±¾Éí£¬¸ü׼ȷµØËµËü´ú±íJSP±»×ªÒëºóµÄServlet£¬Ëü¿ÉÒÔµ÷ÓÃServletÀàËù¶¨ÒåµÄ·½·¨¡£
   
¶þ¡¢config ¶ÔÏó
    config ¶ÔÏóÀï´æ·Å×ÅһЩServlet ³õʼµÄÊý¾Ý½á¹¹¡£
    config ¶ÔÏóʵÏÖÓÚjavax.servlet.ServletConfig ½Ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ