JSP¾Å¸öÄÚÖöÔÏó
ѧϰJ2EE£¬±ØÐë¶ÔÏÂÃæµÄ¼¸¸ö¶ÔÏóÓкÜÉîµÄÀí½â
1¡¢request -> javax.servlet.http.HttpServletRequestµÄʵÀý
¸Ã¶ÔÏó·â×°ÁËÒ»´ÎÇëÇ󣬿ͻ§¶ËµÄÇëÇó²ÎÊý¶¼±»·â×°ÔڸöÔÏóÀï¡£ÕâÊÇÒ»¸ö³£ÓõĶÔÏ󣬻ñÈ¡¿Í»§¶ËÇëÇó²ÎÊý±ØÐëʹÓøöÔÏó¡£³£Óõķ½·¨ÓÐgetParameter(String paramName)¡¢getParameterValues(String paramName)¡¢setAttribute(String atttName,Object attrValue)¡¢getAttribute(String attrName)ºÍsetCharacterEncoding(String env)µÈ¡£
2¡¢response -> javax.servlet.http.HttpServletResponseµÄʵÀý
´ú±í·þÎñÆ÷¶Ô¿Í»§¶ËµÄÏìÓ¦¡£Í¨³£ºÜÉÙʹÓøöÔÏóÖ±½ÓÏìÓ¦£¬¶øÊÇʹÓÃout¶ÔÏ󣬳ý·ÇÐèÒªÉú³É·Ç×Ö·ûÏìÓ¦¡£¶øresponse¶ÔÏó³£ÓÃÓÚÖض¨Ïò£¬³£Óõķ½·¨ÓÐgetOutputStream()¡¢sendRedirect(java.lang.String location)µÈ¡£
3¡¢session -> javax.servlet.http.HttpSessionµÄʵÀý
¸Ã¶ÔÏó´ú±íÒ»´Î»á»°¡£µ±¿Í»§¶Ëä¯ÀÀÆ÷ÓëÕ¾µã½¨Á¢Á¬½Óʱ£¬»á»°¿ªÊ¼£»µ±¿Í»§¶Ë¹Ø±Õä¯ÀÀÆ÷ʱ£¬»á»°½áÊø¡£³£Óõķ½·¨ÓУºgetAttribute(String attrName)¡¢setAttribute(String attrName, Object attrValue)µÈ¡£ÔÚÓû§µÇ¼´¦ÀíµÄʱºò¾³£Ê¹ÓÃÕâ¸ö¶ÔÏó¡£
4¡¢pageContext -> javax.servlet.jsp.PageContextµÄʵÀý
¸Ã¶ÔÏó´ú±í¸ÃJSPÒ³ÃæÉÏÏÂÎÄ£¬Ê¹ÓøöÔÏó¿ÉÒÔ·ÃÎÊÒ³ÃæÖеĹ²ÏíÊý¾Ý¡£³£Óõķ½·¨ÓÐgetServletContext()ºÍgetServletConfig()µÈ¡£¾³£ÔÚJspÖж¨ÒåһЩÊôÐÔ¾ÍÊDZ»·Å½øÕâ¸öʵÀýÖС£
5¡¢application -> javax.servlet.ServletContextµÄʵÀý
¸ÃʵÀý´ú±íJSPËùÊôµÄWebÓ¦Óñ¾Éí£¬¿ÉÓÃÓÚJSPÒ³Ã棬»òÕßServletÖ®¼ä½»»»ÐÅÏ¢¡£³£Óõķ½·¨ÓÐgetAttribute(String attName)¡¢setAttribute(String attName , String attValue)ºÍgetInitParameter(String paramName)µÈ¡£
6¡¢config -> javax.servlet.ServletConfigµÄʵÀý
¸ÃʵÀý´ú±í¸ÃJSPµÄÅäÖÃÐÅÏ¢¡£³£Óõķ½·¨ÓÐgetInitParameter(String paramName)ºÍgetInitParameternames()µÈ·½·¨¡£ÊÂʵÉÏ£¬JSPÒ³Ãæͨ³£ÎÞÐëÅäÖã¬Ò²¾Í²»´æÔÚÅäÖÃÐÅÏ¢¡£Òò´Ë£¬¸Ã¶ÔÏ
Ïà¹ØÎĵµ£º
//ѧϰ±Ê¼Ç, ¿ÉÄÜÓÐЩµØ·½Àí½âÓÐÎó, »á±í´ï²»Çå³þ
v512_servlet+jsp
01 ÔÚÐÞ¸ÄÍêCookieºó,Ò»¶¨Òª¼ÓÉÏresponse.addCookie(c);
CookieÖÐÖ»Äܱ£´æ×Öĸ»òÊý×ÖÐÅÏ¢;
02 req.getSession()Óëreq.getSession(boolean create)
ÎÞ²ÎÊýµÄ == ÓвÎÊýµÄ²ÎÊýÎ ......
ÂÒÂëÕæÊǸöÁîÈËÌÖÑáµÄÎÊÌâ~
¸Õ²ÅÖÕÓÚ°ÑMySQLÓëJSP½»»¥µÄÂÒÂëÎÊÌâ½â¾öÁË¡£
°ì·¨ÈçÏ£º
1.ÔÚurl´¦¼ÓÉϾä×Ó "&useUnicode=true&characterEncoding=GBK" £»
2.ÎÒÓÃNavicat Lite¿ÉÊÓ»¯¹¤¾ß´´½¨MySQLÊý¾Ý¿âʱ£¬¿ÉÑ¡¶¨Êý¾Ý¿â±àÂ룬ҲÊÇ GBK £»
3.Ò³ÃæµÄ±àÂë¿ÉÒÔÑ¡GBKÒÔÍâµÄ±àÂ뷽ʽ£¬ÈçUTF-8¡£Èô²Ù×÷Ò³ÃæµÄ±àÂëÊÇUTF- ......
1 web·þÎñÆ÷{TOMCAT(JSP)¡¢WEBLOGIC(JSP) }
Ó¦Ó÷þÎñÆ÷
We ......
ÎÒÏÖÔÚ¸øÄãÒ»¸öJAVAºÍJSPÖ®¼äµÄ¹Øϵ,ÒÔ¼°JAVAµÄÍêÕûÈÏʶ
JAVA·ÖΪJ2EE,J2SE.J2ME,ÏÂÃæ·Ö±ð½éÉÜ:
Ò».J2EE£ºJava 2 Platform Enterprise Edition ÆóÒµ°æ£¬ÓÃÓÚÆóÒµÓ¦Óã¬Ö§³Ö·Ö²¼Ê½²¿Êð¡£
J2EEƽ̨ÓÉÒ»ÕûÌ×·þÎñ£¨Services£©¡¢Ó¦ÓóÌÐò½Ó¿Ú£¨APIs£©ºÍÐÒé¹¹³É£¬
Ëü¶Ô¿ª·¢»ùÓÚWebµÄ¶à²ãÓ¦ÓÃÌṩÁ˹¦ÄÜÉϵÄÖ§³Ö¡£Ëü°ü ......