Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JSP ÈÝÆ÷µÄ³õʼ»¯ºÍÏú»Ù ServletContext£¨×ª£©

ServletContext ±» Servlet ³ÌÐòÓÃÀ´Óë Web ÈÝÆ÷ͨÐÅ¡£ÀýÈçдÈÕÖ¾£¬×ª·¢ÇëÇó¡£Ã¿Ò»¸ö Web
Ó¦ÓóÌÐòº¬ÓÐÒ»¸öContext£¬±»WebÓ¦ÓÃÄڵĸ÷¸ö³ÌÐò¹²Ïí¡£ÒòΪContext¿ÉÒÔÓÃÀ´±£´æ×ÊÔ´²¢ÇÒ¹²Ïí£¬ËùÒÔÎÒËùÖªµÀµÄ
ServletContext µÄ×î´óÓ¦ÓÃÊÇWeb»º´æ----°Ñ²»¾­³£¸ü¸ÄµÄÄÚÈݶÁÈëÄڴ棬ËùÒÔ·þÎñÆ÷ÏìÓ¦ÇëÇóµÄʱºò¾Í²»ÐèÒª½øÐÐÂýËٵĴÅÅÌI/OÁË¡£
ServletContextListener ÊÇ ServletContext µÄ¼àÌýÕߣ¬Èç¹û ServletContext
·¢Éú±ä»¯£¬Èç·þÎñÆ÷Æô¶¯Ê± ServletContext ±»´´½¨£¬·þÎñÆ÷¹Ø±Õʱ ServletContext ½«Òª±»Ïú»Ù¡£
ÔÚJSP
ÎļþÖУ¬application ÊÇ ServletContext µÄʵÀý£¬ÓÉJSPÈÝÆ÷ĬÈÏ´´½¨¡£Servlet Öе÷ÓÃ
getServletContext()·½·¨µÃµ½ ServletContext µÄʵÀý¡£
ÎÒÃÇʹÓûº´æµÄ˼·´ó¸ÅÊÇ£º
·þ
ÎñÆ÷Æô¶¯Ê±£¬ServletContextListener µÄ
contextInitialized()·½·¨±»µ÷Óã¬ËùÒÔÔÚÀïÃæ´´½¨ºÃ»º´æ¡£¿ÉÒÔ´ÓÎļþÖлòÕß´ÓÊý¾Ý¿âÖжÁÈ¡È¡»º´æÄÚÈÝÉú³ÉÀ࣬ÓÃ
ervletContext.setAttribute()·½·¨½«»º´æÀà±£´æÔÚ ServletContext µÄʵÀýÖС£
³Ì
ÐòʹÓà ServletContext.getAttribute()¶ÁÈ¡»º´æ¡£Èç¹ûÊÇ JSP£¬Ê¹ÓÃa
pplication.getAttribute()¡£Èç¹ûÊÇ Servlet£¬Ê¹ÓÃ

getServletContext().getAttribute()¡£Èç¹û»º´æ·¢Éú±ä»¯(Èç·ÃÎʼÆÊý)£¬Äã¿ÉÒÔͬʱ¸ü¸Ä»º´æºÍÎļþ/Êý¾Ý¿â¡£»òÕßÄãµÈ
±ä»¯»ýÀÛµ½Ò»¶¨³ÌÐòÔÙ±£´æ£¬Ò²¿ÉÒÔÔÚÏÂÒ»²½±£´æ¡£
·þÎñÆ÷½«Òª¹Ø±Õ
ʱ£¬ServletContextListener µÄ
contextDestroyed()·½·¨±»µ÷Óã¬ËùÒÔÔÚÀïÃæ±£´æ»º´æµÄ¸ü¸Ä¡£½«¸ü¸ÄºóµÄ»º´æ±£´æ»ØÎļþ»òÕßÊý¾Ý¿â£¬¸üÐÂÔ­À´µÄÄÚÈÝ¡£
 1
 import
 User; 
//
my own class
 2
 import
 DatabaseManager; 
//
 my own class
 3
 import
 javax.servlet.ServletContext;
 4
 import
 javax.servlet.ServletContextListener;
 5
 
 6
 public
 
class
 MyContextListener
 7
 
 8
     
implements
 ServletContextListener {
 9
     
private
 ServletContext context 
=
 
null
;
10
 
11
     
public
 
void
 contextIniti


Ïà¹ØÎĵµ£º

jspÖÐtableµ¼³ÉexclÎļþ

ÏîÄ¿ÒªÇ󽫺ǫ́Êý¾Ý½øÐÐÏÔʾ£¨ÏÔʾҪÇ󲿷ÖÄÚÈݽøÐÐÁÐÏîºÏ²¢£©£¬ÔÚ¶ÔÏÔʾµÄÊý¾Ý½øÐе¼³ö³Éexcel
ʵÏÖ¹ý³Ì
1¡¢²éѯºÍµ¼³öµÄjspÒ³Ã根ؼü´úÂë
<script language=javascript>
function exportExcel(){
/****ʵÏÖ·½·¨Ò»
<%-- var curTbl = document.getElementById("techQueryTab"); --%>
<%-- ......

JSP»ù´¡

Ò»¡¢JSP¼ò½é
JSP (Java Server Pages)ÊÇ·þÎñÆ÷¶ËµÄ½Å±¾ÓïÑÔ£¬ÊÇÒ»ÖÖÔÚHTMLÒ³ÃæÖмÓÈëJavaÓïÑÔ¶øÉú³É¶¯Ì¬Ò³ÃæµÄ¼¼Êõ£º¼ÓÈëÁËеıêÇ©£¨<%£¬%>£¬…£©¡£
JSPÊÇÒÔJavaºÍServletΪ»ù´¡¿ª·¢¶ø³ÉµÄ¶¯Ì¬ÍøÒ³Éú³É¼¼Êõ£¬ËüµÄµ×²ãʵÏÖÊÇJava Servlet¡£
JSPÒ³ÃæÓÉHTML´úÂëºÍǶÈëÆäÖеÄJava´úÂëËù×é³É¡£·þÎñÆ÷ÔÚÒ³Ãæ±»¿Í» ......

ÔÚTomcat6.0ÖйØÓÚJSP/Servlet±íµ¥ÂÒÂëµÄÒ»¸ö½â¾ö·½·¨

²½ÖèÒ»£º±à¼­TomcatµÄÅäÖÃÎļþconf/server.xmlÔÚÓÃÓÚ½ÓÊÜ¿Í»§¶ËÓï·¨µÄConnector<connector></connector>±êÇ©ÖÐÌí¼ÓURIEncoding="UTF-8"ÊôÐÔ£¬¸ÃÊôÐÔÓÃÀ´½â¾öGETÖеıàÂëÎÊÌâ¡£
xml ´úÂë
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" / ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ