锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲一级二级三级不卡,亚洲黄页网在线观看,国产成人亚洲精品影院http://www.tkk7.com/jackstudio/category/12673.htmlzh-cnWed, 28 Feb 2007 18:07:20 GMTWed, 28 Feb 2007 18:07:20 GMT60spring鏈変笁縐嶅惎鍔ㄦ柟寮?浣跨敤ContextLoaderServlet,ContextLoaderListener鍜孋ontextLoaderPlugIn.http://www.tkk7.com/jackstudio/archive/2006/11/09/80060.htmljackstudiojackstudioThu, 09 Nov 2006 02:40:00 GMThttp://www.tkk7.com/jackstudio/archive/2006/11/09/80060.htmlhttp://www.tkk7.com/jackstudio/comments/80060.htmlhttp://www.tkk7.com/jackstudio/archive/2006/11/09/80060.html#Feedback0http://www.tkk7.com/jackstudio/comments/commentRss/80060.htmlhttp://www.tkk7.com/jackstudio/services/trackbacks/80060.htmlspring鏈変笁縐嶅惎鍔ㄦ柟寮?浣跨敤ContextLoaderServlet,ContextLoaderListener鍜孋ontextLoaderPlugIn.
鐪嬩竴涓婥ontextLoaderListener鐨勬簮鐮?榪欐槸涓涓猄ervletContextListener
/**
聽 * Initialize the root web application context.
聽 */
聽public void contextInitialized(ServletContextEvent event) {
聽 this.contextLoader = createContextLoader();
聽 this.contextLoader.initWebApplicationContext(event.getServletContext());
聽}

聽 /**
聽 * Create the ContextLoader to use. Can be overridden in subclasses.
聽 * @return the new ContextLoader
聽 */
聽protected ContextLoader createContextLoader() {
聽 return new ContextLoader();
聽}

聽contextLoader鐨勬簮鐮?br />聽public WebApplicationContext initWebApplicationContext(ServletContext servletContext)
聽聽 throws BeansException {

聽 long startTime = System.currentTimeMillis();
聽 if (logger.isInfoEnabled()) {
聽聽 logger.info("Root WebApplicationContext: initialization started");
聽 }
聽 servletContext.log("Loading Spring root WebApplicationContext");

聽 try {
聽聽 // Determine parent for root web application context, if any.
聽聽 ApplicationContext parent = loadParentContext(servletContext);

聽聽 WebApplicationContext wac = createWebApplicationContext(servletContext, parent);
聽聽 servletContext.setAttribute(
聽聽聽聽 WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

聽聽 if (logger.isInfoEnabled()) {
聽聽聽 logger.info("Using context class [" + wac.getClass().getName() +
聽聽聽聽聽 "] for root WebApplicationContext");
聽聽 }
聽聽 if (logger.isDebugEnabled()) {
聽聽聽 logger.debug("Published root WebApplicationContext [" + wac +
聽聽聽聽聽 "] as ServletContext attribute with name [" +
聽聽聽聽聽 WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
聽聽 }

聽聽 if (logger.isInfoEnabled()) {
聽聽聽 long elapsedTime = System.currentTimeMillis() - startTime;
聽聽聽 logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
聽聽 }

聽聽 return wac;
聽 }
聽 catch (RuntimeException ex) {
聽聽 logger.error("Context initialization failed", ex);
聽聽 servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
聽聽 throw ex;
聽 }
聽 catch (Error err) {
聽聽 logger.error("Context initialization failed", err);
聽聽 servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
聽聽 throw err;
聽 }
聽}
聽娉ㄦ剰WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,榪欓噷闈㈡斁浜哤ebApplicationContext,闇瑕佷嬌鐢ㄦ椂浠嶴ervletContext鍙栧嚭
聽鍙互浣跨敤WebApplicationContextUtils寰楀埌WebApplicationContext
聽public static WebApplicationContext getWebApplicationContext(ServletContext sc) {
聽 Object attr = sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
聽 if (attr == null) {
聽聽 return null;
聽 }
聽 if (attr instanceof RuntimeException) {
聽聽 throw (RuntimeException) attr;
聽 }
聽 if (attr instanceof Error) {
聽聽 throw (Error) attr;
聽 }
聽 if (!(attr instanceof WebApplicationContext)) {
聽聽 throw new IllegalStateException("Root context attribute is not of type WebApplicationContext: " + attr);
聽 }
聽 return (WebApplicationContext) attr;
聽}
聽鍏抽敭鐨勯棶棰樺湪浜巗truts濡備綍鍚姩鐨剆pring鐨?ContextLoaderPlugIn鐨勬簮鐮?br />聽
聽// Publish the context as a servlet context attribute.
聽 String attrName = getServletContextAttributeName();
聽 getServletContext().setAttribute(attrName, wac);

聽public String getServletContextAttributeName() {
聽 return SERVLET_CONTEXT_PREFIX + getModulePrefix();
聽}
聽涓嶅悓鍔犺澆鐨凨ey绔熺劧涓嶅悓,鍘熷洜灝辨槸WebApplicationContext鏀懼湪閭i噷鐨勯棶棰?鍙痵pring璋冪敤鐨勬椂鍊欎細鏍規(guī)嵁WebApplicationContext閲岄潰瀹氫箟鐨勯偅涓悕瀛楀幓鎵劇殑,闂鍑哄湪榪欓噷


聽鍦╯truts-config.xml涓厤緗?br />聽聽聽 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
聽聽聽聽聽 <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
聽聽聽 </plug-in>

聽聽聽 <controller>
聽聽聽聽聽聽聽 <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor" />
聽聽聽 </controller>


聽鍘熺悊鏄繖鏍風殑,Struts铏界劧鍙兘鏈変竴涓狝ctionServlet瀹炰緥,浣嗘槸瀵逛簬涓嶅悓鐨勫瓙搴旂敤鍒嗗埆鑳芥湁鑷繁鐨凴equestProcessor瀹炰緥姣忎釜RequestProcessor瀹炰緥鍒嗗埆瀵瑰簲涓嶅悓鐨剆truts閰嶇疆鏂囦歡銆?br />聽聽 瀛愬簲鐢ㄧ殑ProcessorClass綾誨繀欏婚噸鍐欎竴鑸氨鏄戶鎵縍equestProcessor綾伙紝鐒跺悗鍐嶅叾閰嶇疆鏂囦歡鐨刢ontroller鍏冪礌涓殑<processorClass>灞炴т腑浣滃嚭淇敼銆傞偅涔堝綋
聽 getRequestProcessor(getModuleConfig(request)).process(request,response);灝辮兘鏍規(guī)嵁request閫夋嫨鐩稿簲鐨刴oduleconfig,鍐嶆牴鎹叾<processorClass>灞炴ч夋嫨鐩稿簲鐨凴equestProcessor瀛愮被鏉ュ鐞嗙浉搴旂殑璇鋒眰浜嗐?/p>



]]>
浣跨敤ServletContextListener鍦ㄦ湇鍔″櫒鍚姩鍜屽叧闂椂鍒涘緩鍜屽叧闂紦瀛?/title><link>http://www.tkk7.com/jackstudio/archive/2006/11/09/80058.html</link><dc:creator>jackstudio</dc:creator><author>jackstudio</author><pubDate>Thu, 09 Nov 2006 02:39:00 GMT</pubDate><guid>http://www.tkk7.com/jackstudio/archive/2006/11/09/80058.html</guid><wfw:comment>http://www.tkk7.com/jackstudio/comments/80058.html</wfw:comment><comments>http://www.tkk7.com/jackstudio/archive/2006/11/09/80058.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jackstudio/comments/commentRss/80058.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jackstudio/services/trackbacks/80058.html</trackback:ping><description><![CDATA[ <div id="ljfdjrd" class="con_sample"> <p>ServletContext 琚?Servlet 紼嬪簭鐢ㄦ潵涓?Web 瀹瑰櫒閫氫俊銆備緥濡傚啓鏃ュ織錛岃漿鍙戣姹傘傛瘡涓涓?Web 搴旂敤紼嬪簭鍚湁涓涓狢ontext錛岃Web搴旂敤鍐呯殑鍚勪釜紼嬪簭鍏變韓銆傚洜涓篊ontext鍙互鐢ㄦ潵淇濆瓨璧勬簮騫朵笖鍏變韓錛屾墍浠ユ垜鎵鐭ラ亾鐨?ServletContext 鐨勬渶澶у簲鐢ㄦ槸Web緙撳瓨----鎶婁笉緇忓父鏇存敼鐨勫唴瀹硅鍏ュ唴瀛橈紝鎵浠ユ湇鍔″櫒鍝嶅簲璇鋒眰鐨勬椂鍊欏氨涓嶉渶瑕佽繘琛屾參閫熺殑紓佺洏I(yè)/O浜嗐?/p> </div> <div id="vvdrldd" class="con_all"> <p> </p> <p>ServletContext 琚?Servlet 紼嬪簭鐢ㄦ潵涓?Web 瀹瑰櫒閫氫俊銆備緥濡傚啓鏃ュ織錛岃漿鍙戣姹傘傛瘡涓涓?Web 搴旂敤紼嬪簭鍚湁涓涓狢ontext錛岃Web搴旂敤鍐呯殑鍚勪釜紼嬪簭鍏變韓銆傚洜涓篊ontext鍙互鐢ㄦ潵淇濆瓨璧勬簮騫朵笖鍏變韓錛屾墍浠ユ垜鎵鐭ラ亾鐨?ServletContext 鐨勬渶澶у簲鐢ㄦ槸Web緙撳瓨----鎶婁笉緇忓父鏇存敼鐨勫唴瀹硅鍏ュ唴瀛橈紝鎵浠ユ湇鍔″櫒鍝嶅簲璇鋒眰鐨勬椂鍊欏氨涓嶉渶瑕佽繘琛屾參閫熺殑紓佺洏I(yè)/O浜嗐?</p> <p>ServletContextListener 鏄?ServletContext 鐨勭洃鍚咃紝濡傛灉 ServletContext 鍙戠敓鍙樺寲錛屽鏈嶅姟鍣ㄥ惎鍔ㄦ椂 ServletContext 琚垱寤猴紝鏈嶅姟鍣ㄥ叧闂椂 ServletContext 灝嗚琚攢姣併?</p> <p>鍦↗SP鏂囦歡涓紝application 鏄?ServletContext 鐨勫疄渚嬶紝鐢盝SP瀹瑰櫒榛樿鍒涘緩銆係ervlet 涓皟鐢?getServletContext()鏂規(guī)硶寰楀埌 ServletContext 鐨勫疄渚嬨?</p> <p>鎴戜滑浣跨敤緙撳瓨鐨勬濊礬澶ф鏄細 </p> <ol> <li> <p>鏈嶅姟鍣ㄥ惎鍔ㄦ椂錛孲ervletContextListener 鐨?contextInitialized()鏂規(guī)硶琚皟鐢紝鎵浠ュ湪閲岄潰鍒涘緩濂界紦瀛樸傚彲浠ヤ粠鏂囦歡涓垨鑰呬粠鏁版嵁搴撲腑璇誨彇鍙栫紦瀛樺唴瀹圭敓鎴愮被錛岀敤 ervletContext.setAttribute()鏂規(guī)硶灝嗙紦瀛樼被淇濆瓨鍦?ServletContext 鐨勫疄渚嬩腑銆?</p> </li> <li> <p>紼嬪簭浣跨敤 ServletContext.getAttribute()璇誨彇緙撳瓨銆傚鏋滄槸 JSP錛屼嬌鐢╝ pplication.getAttribute()銆傚鏋滄槸 Servlet錛屼嬌鐢?getServletContext().getAttribute()銆傚鏋滅紦瀛樺彂鐢熷彉鍖?濡傝闂鏁?錛屼綘鍙互鍚屾椂鏇存敼緙撳瓨鍜屾枃浠?鏁版嵁搴撱傛垨鑰呬綘絳?鍙樺寲縐瘡鍒頒竴瀹氱▼搴忓啀淇濆瓨錛屼篃鍙互鍦ㄤ笅涓姝ヤ繚瀛樸?</p> </li> <li> <p>鏈嶅姟鍣ㄥ皢瑕佸叧闂椂錛孲ervletContextListener 鐨?contextDestroyed()鏂規(guī)硶琚皟鐢紝鎵浠ュ湪閲岄潰淇濆瓨緙撳瓨鐨勬洿鏀廣傚皢鏇存敼鍚庣殑緙撳瓨淇濆瓨鍥炴枃浠舵垨鑰呮暟鎹簱錛屾洿鏂板師鏉ョ殑鍐呭銆?</p> </li> </ol> <pre>import User; //my own class<br />import DatabaseManager; // my own class<br />import javax.servlet.ServletContext;<br />import javax.servlet.ServletContextListener;<br /><br />public class MyContextListener<br /><br /> implements ServletContextListener {<br /> private ServletContext context = null;<br /><br /> public void contextInitialized(ServletContextEvent event) {<br /> context = event.getServletContext();<br /> User user = DatabaseManager.getUserById(1);<br /> context.setAttribute("user1", user);<br /> }<br /><br /> public void contextDestroyed(ServletContextEvent event) {<br /> User user = (User)context.getAttribute("user1");<br /> DatabaseManager.updateUserData(user);<br /> this.context = null;<br /> }<br />}<br /></pre> <h3 class="para">甯冪講 ServletContextListener</h3> <p>浣犲疄鐜?implements)浜?ServletContextListener 緙栬瘧鍚庯紝鎶婂畠鏀懼湪姝g‘鐨刉EB-INF/classes鐩綍涓嬶紝鏇存敼WEB-INF鐩綍涓嬬殑 web.xml鏂囦歡錛屽湪web-app鑺傜偣閲屾坊鍔?</p> <pre><listener><br /> <listener-class>MyServletContextListener</listener-class><br /></listener><br /></pre>聽鏉ヨ嚜錛?a s blog</a></div> <img src ="http://www.tkk7.com/jackstudio/aggbug/80058.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jackstudio/" target="_blank">jackstudio</a> 2006-11-09 10:39 <a href="http://www.tkk7.com/jackstudio/archive/2006/11/09/80058.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍏充簬Spring , Struts緇撳悎瀛︿範http://www.tkk7.com/jackstudio/archive/2006/09/21/71106.htmljackstudiojackstudioThu, 21 Sep 2006 07:04:00 GMThttp://www.tkk7.com/jackstudio/archive/2006/09/21/71106.htmlhttp://www.tkk7.com/jackstudio/comments/71106.htmlhttp://www.tkk7.com/jackstudio/archive/2006/09/21/71106.html#Feedback0http://www.tkk7.com/jackstudio/comments/commentRss/71106.htmlhttp://www.tkk7.com/jackstudio/services/trackbacks/71106.html闃呰鍏ㄦ枃

]]>
主站蜘蛛池模板: 中文字幕 亚洲 有码 在线| 久久伊人久久亚洲综合| 亚洲日韩国产二区无码| 性色av免费观看| 亚洲第一成年网站视频| 四只虎免费永久观看| 国产亚洲午夜精品| 免费一级毛片在播放视频| 精品国产亚洲第一区二区三区| 精品无码国产污污污免费| 亚洲av无码成人影院一区 | 成人免费的性色视频| 亚洲国产综合第一精品小说| 日日麻批免费40分钟日本的| 亚洲中文字幕久久精品无码VA| 免费黄色网址入口| 日本免费精品一区二区三区| 久久亚洲精品无码观看不卡| 中国一级特黄高清免费的大片中国一级黄色片 | 亚洲综合色婷婷在线观看| 夭天干天天做天天免费看| 成人精品国产亚洲欧洲| 亚洲欧洲国产成人综合在线观看 | 亚洲区小说区激情区图片区| **aaaaa毛片免费同男同女| 亚洲夂夂婷婷色拍WW47| 亚洲国产小视频精品久久久三级| 在线免费观看h片| 亚洲欧洲校园自拍都市| 四虎成人免费影院网址| 成人片黄网站色大片免费观看cn| 亚洲日韩国产精品无码av| 国产精品二区三区免费播放心| 久久久WWW免费人成精品| 亚洲激情黄色小说| 四虎永久在线精品免费观看地址 | 亚洲日韩中文字幕天堂不卡| 免费一级毛片不卡在线播放| 最近新韩国日本免费观看| 特级毛片A级毛片免费播放| 久久久久久久久亚洲|