JSPÖж¯Ì¬INCLUDEÓ뾲̬INCLUDEµÄÇø±ð
ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
<%@ include file=" "%>
<jsp:include page=" " flush="true"/>
Ç°ÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐΪԪËØ.
ͨ³£µ±Ó¦ÓóÌÐòÖÐËùÓеÄÒ³ÃæµÄijЩ²¿·Ö(ÀýÈç±êÌâ¡¢Ò³½ÅºÍµ¼º½À¸)¶¼ÏàͬµÄʱºò,ÎÒÃǾͿÉÒÔ¿¼ÂÇÓÃinclude.¾ßÌåÔÚÄÄЩʱºòÓÃ<%@ include file=" "%>,ÄÄЩʱºòÓÃ<jsp:include page=" " flush="true"/>.ÕâÖÖÐÎʽ.Ê×ÏÈÒªÃ÷°×µÄÊÇËüÃÇÖ®¼äµÄÇø±ð.
<%@ include file=" "%>,jspµÄincludeÖ¸ÁîÔªËضÁÈëÖ¸¶¨Ò³ÃæµÄÄÚÈÝ.²¢°ÑÕâЩÄÚÈݺÍÔÀ´µÄÒ³ÃæÈںϵ½Ò»Æð.(Õâ¸ö¹ý³ÌÊÇÔÚ·Òë½×¶Î:Ò²¾ÍÊÇjsp±»×ª»¯³ÉservletµÄ½×¶Î½øÐеģ©.
ÕâÀï¶Ô·Òë½×¶Î½øÐÐÒ»ÏÂ˵Ã÷:ÎÒÃÇÖªµÀ,jspÒ³Ãæ²»ÄÜÔ·â²»¶¯µØ±»´«Ë͸øä¯ÀÀÆ÷,ËùÓеÄjspÔªËض¼±ØÐëÊ×ÏÈÓÉ·þÎñÆ÷½øÐд¦Àí.ÕâÊÇͨ¹ý½«jspÒ³Ãæת´ï»¯³Éservlet,È»ºóÖ´ÐÐÕâ¸öservletÀ´Íê³ÉµÄ.·þÎñÆ÷ÐèÒªÒ»¸öjspÈÝÆ÷À´´¦ÀíjspÒ³Ãæ.jspÈÝÆ÷ͨ³£ÒÔservletµÄÐÎʽÀ´ÊµÏÖ,Õâ¸öservlet¾¹ýÅäÖÃ,¿ÉÒÔ´¦Àí¶ÔjspÒ³ÃæµÄËùÓÐÇëÇó.
JspÈÝÆ÷¸ºÔð½«jspÒ³Ãæת»¯³Éservlet(³ÆΪjspÒ³ÃæʵÏÖÀà?JSP Page implementation class),²¢±àÒëÕâ¸öservlet.ÕâÁ½²½¾Í¹¹³ÉÁË·Òë½×¶Î.
ÓÉ´ËÎÒÃǾͻáÖªµÀ:jspÒ³ÃæÊÇ°ÑincludeÖ¸ÁîÔªËØËùÖ¸¶¨µÄÒ³ÃæµÄʵ¼ÊÄÚÈÝ(Ò²¾ÍÊÇ´úÂë¶Î)¼ÓÈëµ½ÒýÈëËüµÄjspÒ³ÃæÖÐ,ºÏ³ÉÒ»¸öÎļþºó±»jspÈÝÆ÷½«Ëüת»¯³Éservlet.¿ÉÒÔ¿´µ½Õâʱ»á²úÉúÒ»¸öÁÙʱclassÎļþºÍÒ»¸öjavaÎļþ.ÏÂÃæ¾Ù¸öÀý×Ó.
·þÎñÆ÷ÓÃtomcat,ÒýÈëÒ³ÃæµÄjspÎļþ½Ðtest.jsp.±»ÒýÈëµÄÒ³Ãæ½Ðdate.jsp.Õâ¸öjspÎļþÀï´æ·ÅµÄÊÇÒ»¸öÓйØʱ¼äµÄjsp´úÂë,µ±Ç°µÄÉÏÏÂÎĸùÉèΪtest
//======date.jspµÄÔ´Îļþ=====//
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%
java.util.Date date=new java.util.Date();
String date_cn ="";
String dateStr = "";
switch(date.getDay())
{
case 0:date_cn ="ÈÕ"; break;
case 1:date_cn ="Ò»"; break;
case 2:date_cn ="¶þ"; bre
Ïà¹ØÎĵµ£º
ÔÚJava web¿ª·¢Öг£»áʹÓõ½¹¦ÄÜÇ¿´óµÄ¹ýÂËÆ÷£¬Ëû±Ï¾¹ÄܸøÎÒÃÇ´øÀ´ºÜ´óµÄ·½±ã£¬µ«ÊÇÕë¶Ô¹ýÂ˵Ä×ÊÔ´ÎÒÃÇÐèÒªÏêϸµÄÁ˽âËûÃÇÔÚweb.xmlÖеÄÅäÖÃÐÅÏ¢¡£Õâ¸ö¸ù¾Ý¼¸ÖÖ³£ÓõIJ»Í¬Çé¿ö½øÐÐÁË×ܽ᣺
1.Èç¹ûÒªÓ³Éä¹ýÂËÓ¦ÓóÌÐòÖÐËùÓÐ×ÊÔ´£º
<filter>
<filter-name>loggerfilter</filter-name> ......
ºÜ¾ÃûÓÐÓÃMysqlÁË£¬·¢ÏÖССµÄʱ¼äÎÊÌâÒ²Óöµ½²»ÉÙÂé·³£¬ºÇºÇ
ËùÒÔ×ܽáһϣº
µÚÒ»ÖÖ:
Date time= new java.sql.Date(new java.util.Date().getTime());
µÚ¶þÖÖ:
java ÓÃPreparedStatementÀ´setDate,ÓÃÎʺŵÄÐÎʽ¸øÈÕÆÚÎʺŸ³Öµ
pstmt.setTimestamp(8, new Timestamp(System.currentTimeMillis()));
pst ......
request request±íʾHttpServletRequest¶ÔÏó¡£Ëü°üº¬ÁËÓйØä¯ÀÀÆ÷ÇëÇóµÄÐÅÏ¢£¬²¢ÇÒÌṩÁ˼¸¸öÓÃÓÚ»ñÈ¡cookie, header, ºÍsessionÊý¾ÝµÄÓÐÓõķ½·¨¡£
response response±íʾHttpServletResponse¶ÔÏ󣬲¢ÌṩÁ˼¸¸öÓÃÓÚÉèÖÃËÍ»Ø ä¯ÀÀÆ÷µÄÏìÓ¦µÄ·½·¨£¨Èçcookies,Í·ÐÅÏ¢µÈ£©
out out ¶ÔÏóÊÇjavax.jsp.JspWriterµÄÒ»¸öʵÀý£¬ ......
ÔÚtomcatÏÂÕÒµ½tomcat -> conf -> server.xml ÔÚÕâÒ»¾äÖÐÌí¼ÓºìÉ«²¿·Ö
<Connector connectionTimeout="20000" port="9090" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"
/> <!--URLEncoding=""--> ± ......
JSPÒ³ÃæÖÐÒ»°ãÓÐÁ½Àà×¢ÊÍ
1.html×¢ÊÍ
ÐÎÈç<!--...................-->
Ëü»áͬhtml±ê¼Çһͬ·¢µ½¿Í»§¶Ë
2.jsp×¢ÊÍ£¨3ÖÖ£©
ÐÎÈç<%--.............................--%>
Ëü²»»á±»·¢Ë͵½¿Í»§¶Ë£¬Ö»ÓÃÀ´×¢ÊÍ·þÎñÆ÷¶ËµÄjspÎļþ£¬Á¬jspÉú³ÉµÄservletҲûÓÐ×¢ÊͽøÈ¥£¬ÕâÒ²ÊǴ󲿷ÖÈËʹÓõÄ×¢ÊÍ
ÐÎÈç<%//...... ......