freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

javaweb服務(wù)器jetty使用手冊(cè)-文庫(kù)吧

2024-10-14 20:24 本頁(yè)面


【正文】 ?xml version=? !DOCTYPE Configure PUBLIC //Jetty//Configure//EN Configure id=FileServer class= Call name=addConnector Arg New class= Set name=port8080/Set /New /Arg /Call Set name=handler New class= Set name=handlers Array type= Item New class= Set name=directoriesListedtrue/Set Set name=weleFiles Array type=StringItem/Item/Array /Set Set name=resourceBase./Set /New /Item Item New class= /New /Item /Array /Set /New /Set /Configure 你可以 在 里面運(yùn)行這個(gè) XML文件: public class FileServerXml { public static void main(String[] args) throws Exception { Resource fileserver_xml = ()。 XmlConfiguration configuration = new XmlConfiguration(())。 Server server = (Server)()。 ()。 ()。 } } 使用 Spring 來(lái)配置一個(gè)文件服務(wù)器 你可以用 Spring 框架 來(lái)組裝 Jetty 服務(wù)器,上面的文件服務(wù)器例子可以用Spring 配置來(lái)寫(xiě): beans bean id=Server class= initmethod=start destroymethod=stop property name=connectors list bean id=Connector class= property name=port value=8080/ /bean /list /property property name=handler bean id=handlers class= property name=handlers list bean class= property name=directoriesListed value=true/ property name=weleFiles list value/value /list /property property name=resourceBase value=./ /bean bean class=/ /list /property /bean /property /bean /beans 設(shè)置上下文 一個(gè)上下文處理器 是一個(gè)處理器封裝器,它只會(huì)響應(yīng)哪些擁有一個(gè)和配置的上下文路徑相匹配的 URI 前綴的請(qǐng)求。 不匹配的請(qǐng)求不會(huì)被處理。 下面的代碼為 hello 處理器設(shè)置上下文路徑和類加載器: public class OneContext { public static void main(String[] args) throws Exception { Server server = new Server(8080)。 ContextHandler context = new ContextHandler()。 (/hello)。 (.)。 (().getContextClassLoader())。 (context)。 (new HelloHandler())。 ()。 ()。 } } 創(chuàng)建 servlet servlet 是提供處理 HTTP 請(qǐng)求的程序邏輯的標(biāo)準(zhǔn)方式。 servlet 就像是強(qiáng)制的處理器,它用標(biāo)準(zhǔn)的方式去匹配特定的 URI 和特定的 servlet。 public class HelloServlet extends HttpServlet { private String greeting=Hello World。 public HelloServlet(){} public HelloServlet(String greeting) { =greeting。 } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { (text/html)。 ()。 ().println(h1+greeting+/h1)。 ().println(session= + (true).getId())。 } } 設(shè)置一個(gè) servlet 上下文 一個(gè) servlet 上下文處理器是一個(gè)能夠支持標(biāo)準(zhǔn) servlet 的特殊的上下文處理器。下面的代碼顯示 3 個(gè)注冊(cè)到一個(gè) servlet 上下文處理器的 helloworld servlet 實(shí)例。 public class OneServletContext { public static void main(String[] args) throws Exception { Server server = new Server(8080)。 ServletContextHandler context = new ServletContextHandler()。 (/)。 (context)。 (new ServletHolder(new HelloServlet()),/*)。 (new ServletHolder(new HelloServlet(Buongiorno Mondo)),/it/*)。 (new ServletHolder(new HelloServlet(Bonjour le Monde)),/fr/*)。 ()。 ()。 } } 設(shè)置一個(gè) web 應(yīng)用程序上下文 一個(gè) web 應(yīng)用程序上下文 是一個(gè) servlet 上下文處理器的變種,它使用標(biāo)準(zhǔn)的布局和 來(lái)配置 servlet、過(guò)濾器和其它特性: public class OneWebApp { public static void main(String[] args) throws Exception { String jetty_home = (,..)。 Server server = new Server(8080)。 WebAppContext webapp = new WebAppContext()。 (/)。 (jetty_home+/webapps/)。 (webapp)。 ()。 ()。 } } 配置一個(gè)上下文處理器集合 一個(gè)上下文處理器集合使用最長(zhǎng)的請(qǐng)求 URI 前綴( 上下文路徑 ) 來(lái)選擇特定的上下文。下面的例子把上面的兩個(gè)例子組合到一個(gè) Jetty 服務(wù)器里: public class ManyContexts { public static void main(String[] args) throws Exception { Server server = new Server(8080)。 ServletContextHandler context0 = new ServletContextHandler()。 (/ctx0)。 (new ServletHolder(new HelloServlet()),/*)。 (new ServletHolder(new HelloServlet(Buongiorno Mondo)),/it/*)。 (new ServletHolder(new HelloServlet(Bonjour le Monde)),/fr/*)。 WebAppContext webapp = new WebAppContext()。 (/ctx1)。 (jetty_home+/webapps/)。 ContextHandlerCollection contexts = new ContextHandlerCollection()。 (new Handler[] { context0, webapp })。 (contexts)。 ()。 ()。 } } 3. 配置 Jetty 用法 介紹 Jetty 提供一個(gè)基于 XML 的配置 。它是基于 Java 的反射機(jī)制 API。在 里面的類代表 Java 的方法和類,你可以根據(jù)它們的名字和參數(shù)類型來(lái)初始化對(duì)象和調(diào)用它們的方法。在后臺(tái), Jetty 的 XML 配置解析器把XML 元素和屬性轉(zhuǎn)化成反射機(jī)制調(diào)用。 使用 要想使用 , 啟動(dòng) Jetty 的時(shí)候指定它作為配置文件。 java jar etc/ 關(guān)于配置文件的小提示 : 如果你啟動(dòng) Jetty 而沒(méi)有指定配置文件, Jetty 會(huì)自動(dòng)定位和使用默認(rèn)安裝的 文件。因此 java jar 和 java jar etc/ 是一樣的。 多個(gè)配置文件 你 并沒(méi)有被限制只能使用一個(gè)配置文件。運(yùn)行 J
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1