jspµÄweb.xmlÅäÖÃ˵Ã÷
Web.xml³£ÓÃÔªËØ
<web-app>
<display-name></display-name>¶¨ÒåÁËWEBÓ¦ÓõÄÃû×Ö
<description></description> ÉùÃ÷WEBÓ¦ÓõÄÃèÊöÐÅÏ¢
<context-param></context-param> context-paramÔªËØÉùÃ÷Ó¦Ó÷¶Î§Äڵijõʼ»¯²ÎÊý¡£
<filter></filter> ¹ýÂËÆ÷ÔªËؽ«Ò»¸öÃû×ÖÓëÒ»¸öʵÏÖjavax.servlet.Filter½Ó¿ÚµÄÀàÏà¹ØÁª¡£
<filter-mapping></filter-mapping> Ò»µ©ÃüÃûÁËÒ»¸ö¹ýÂËÆ÷£¬¾ÍÒªÀûÓÃfilter-mappingÔªËØ°ÑËüÓëÒ»¸ö»ò¶à¸öservlet»òJSPÒ³ÃæÏà¹ØÁª¡£
<listener></listener>servlet APIµÄ°æ±¾2.3Ôö¼ÓÁ˶Ôʼþ¼àÌý³ÌÐòµÄÖ§³Ö£¬Ê¼þ¼àÌý³ÌÐòÔÚ½¨Á¢¡¢Ð޸ĺÍɾ³ý»á»°»òservlet»·¾³Ê±µÃµ½Í¨Öª¡£
ListenerÔªËØÖ¸³öʼþ¼àÌý³ÌÐòÀà¡£
<servlet></servlet> ÔÚÏòservlet»òJSPÒ³ÃæÖƶ¨³õʼ»¯²ÎÊý»ò¶¨ÖÆURLʱ£¬±ØÐëÊ×ÏÈÃüÃûservlet»òJSPÒ³Ãæ¡£ServletÔªËؾÍÊÇÓÃÀ´Íê³É´ËÏîÈÎÎñµÄ¡£
<servlet-mapping></servlet-mapping> ·þÎñÆ÷Ò»°ãΪservletÌṩһ¸öȱʡµÄURL£ºhttp://host/webAppPrefix/servlet/ServletName¡£
µ«ÊÇ£¬³£³£»á¸ü¸ÄÕâ¸öURL£¬ÒÔ±ãservlet¿ÉÒÔ·ÃÎʳõʼ»¯²ÎÊý»ò¸üÈÝÒ׵ش¦ÀíÏà¶ÔURL¡£ÔÚ¸ü¸ÄȱʡURLʱ£¬Ê¹ÓÃservlet-mappingÔªËØ¡£
<session-config></session-config> Èç¹ûij¸ö»á»°ÔÚÒ»¶¨Ê±¼äÄÚδ±»·ÃÎÊ£¬·þÎñÆ÷¿ÉÒÔÅ×ÆúËüÒÔ½ÚÊ¡ÄÚ´æ¡£
¿Éͨ¹ýʹÓÃHttpSessionµÄsetMaxInactiveInterval·½·¨Ã÷È·ÉèÖõ¥¸ö»á»°¶ÔÏóµÄ³¬Ê±Öµ£¬»òÕß¿ÉÀûÓÃsession-configÔªËØÖƶ¨È±Ê¡³¬Ê±Öµ¡£
<mime-mapping></mime-mapping>Èç¹ûWebÓ¦ÓþßÓÐÏëµ½ÌØÊâµÄÎļþ£¬Ï£ÍûÄܱ£Ö¤¸øËûÃÇ·ÖÅäÌض¨µÄMIMEÀàÐÍ£¬Ôòmime-mappingÔªËØÌṩÕâÖÖ±£Ö¤¡£
<welcome-file-list></welcome-file-list> ָʾ·þÎñÆ÷ÔÚÊÕµ½ÒýÓÃÒ»¸öĿ¼Ãû¶ø²»ÊÇÎļþÃûµÄURLʱ£¬Ê¹ÓÃÄĸöÎļþ¡£
<error-page></error-page> ÔÚ·µ»ØÌض¨HTTP״̬´úÂëʱ£¬»òÕßÌض¨ÀàÐ͵ÄÒì³£±»Å׳öʱ£¬Äܹ»Öƶ¨½«ÒªÏÔʾµÄÒ³Ãæ¡£
<taglib></taglib> ¶Ô±ê¼Ç¿âÃèÊö·ûÎļþ£¨Tag
Ïà¹ØÎĵµ£º
12.1 JSP½Å±¾ÔªËØ
¡¡¡¡ JSP½Å±¾ÔªËØÓÃÀ´²åÈëJava´úÂ룬ÕâЩJava´úÂ뽫³öÏÖÔÚÓɵ±Ç°JSPÒ³ÃæÉú³ÉµÄServletÖС£½Å±¾ÔªËØÓÐÈýÖÖ¸ñʽ£º
±í´ïʽ¸ñʽ£¼%= expression %£¾£º¼ÆËã±í´ïʽ²¢Êä³öÆä½á¹û¡£
Scriptlet¸ñʽ£¼% code %£¾£º°Ñ´úÂë²åÈëµ½ServletµÄservice·½·¨¡£
ÉùÃ÷¸ñʽ£¼%! code %£¾£º°ÑÉùÃ÷¼ÓÈëµ½ServletÀࣨÔÚÈκη ......
JSP¶¯×÷ÀûÓÃXMLÓï·¨¸ñʽµÄ±ê¼ÇÀ´¿ØÖÆServletÒýÇæµÄÐÐΪ¡£ÀûÓÃJSP¶¯×÷¿ÉÒÔ¶¯Ì¬µØ²åÈëÎļþ¡¢ÖØÓÃJavaBean×é¼þ¡¢°ÑÓû§Öض¨Ïòµ½ÁíÍâµÄÒ³Ã桢ΪJava²å¼þÉú³ÉHTML´úÂë¡£
JSP¶¯×÷°üÀ¨£º
jsp:include£ºÔÚÒ³Ãæ±»ÇëÇóµÄʱºòÒýÈëÒ»¸öÎļþ¡£
jsp:useBean£ºÑ°ÕÒ»òÕßʵÀý»¯Ò»¸öJavaBean¡£
jsp:setProperty£ºÉèÖÃJavaBeanµÄÊôÐÔ¡£ ......
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Óʱ³öÏÖÂÒÂë
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾ ......
1 £©Ê×ÏȽ¨Á¢¹ÜÀíÓû§±í£¬ÆäÖÐ UserPopedom ¼Ç¼Óû§µÄȨÏÞ×Ö·û£¬ÆäʵҲ¾ÍÊÇһЩ JSP »òÕß ACTION µÄÎļþÃû£º
CREATE TABLE [dbo].[AdminUser] (
[UserID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[UserName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[UserPass] [varchar ......