Jetty实战之 嵌入式Jetty运行web app
Jetty實(shí)戰(zhàn)之 嵌入式Jetty運(yùn)行web app
博客分類:- ?
- 應(yīng)用服務(wù)器
轉(zhuǎn)載地址:http://blog.csdn.net/kongxx/article/details/7237034
要說(shuō)嵌入式運(yùn)行Jetty,最常用的還應(yīng)該是運(yùn)行一個(gè)標(biāo)準(zhǔn)的war文件或者指定一個(gè)webapp目錄。
0. 首先需要添加Jetty運(yùn)行時(shí)webapp的依賴包,下面是一個(gè)完整的pom.xml文件
寫(xiě)道 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">?
<modelVersion>4.0.0</modelVersion>?
<groupId>com.google.code.garbagecan.jettystudy</groupId>?
<artifactId>jettystudy</artifactId>?
<packaging>jar</packaging>?
<version>1.0-SNAPSHOT</version>?
<name>jettystudy</name>?
<url>http://maven.apache.org</url>?
<build>?
<plugins>?
<plugin>?
<artifactId>maven-compiler-plugin</artifactId>?
<inherited>true</inherited>?
<version>2.3.1</version>?
<configuration>?
<source>1.6</source>?
<target>1.6</target>?
<debug>true</debug>?
</configuration>?
</plugin>?
</plugins>?
</build>?
<dependencies>?
<!-- Spring support -->?
<dependency>?
<groupId>org.springframework</groupId>?
<artifactId>spring</artifactId>?
<version>2.5.6</version>?
</dependency>?
<!-- Jetty -->?
<dependency>?
<groupId>org.eclipse.jetty.aggregate</groupId>?
<artifactId>jetty-all</artifactId>?
<version>8.0.4.v20111024</version>?
</dependency>?
<!-- Jetty Webapp -->?
<dependency>?
<groupId>org.eclipse.jetty</groupId>?
<artifactId>jetty-webapp</artifactId>?
<version>8.0.4.v20111024</version>?
</dependency>?
<!-- JSP Support -->?
<dependency>?
<groupId>org.glassfish.web</groupId>?
<artifactId>javax.servlet.jsp</artifactId>?
<version>2.2.3</version>?
</dependency>?
<!-- EL Support -->?
<dependency>?
<groupId>org.glassfish.web</groupId>?
<artifactId>javax.el</artifactId>?
<version>2.2.3</version>?
</dependency>?
<!-- JSTL Support -->?
<dependency>?
<groupId>org.glassfish.web</groupId>?
<artifactId>javax.servlet.jsp.jstl</artifactId>?
<version>1.2.1</version>?
<exclusions>?
<exclusion>?
<artifactId>jstl-api</artifactId>?
<groupId>javax.servlet.jsp.jstl</groupId>?
</exclusion>?
</exclusions>?
</dependency>?
</dependencies>?
</project>
?1. 運(yùn)行標(biāo)準(zhǔn)的war文件
1.1 首先找一個(gè)完整的war包,這里使用了struts2自帶的一個(gè)例子應(yīng)用程序struts2-blank.war;
1.2 創(chuàng)建自己的Jetty Server啟動(dòng)類WebAppContextWithWarServer,其中指定了war文件的路徑,并指定context路徑為"/myapp"
Java代碼???1.3 運(yùn)行WebAppContextWithWarServer類,然后訪問(wèn)// http://localhost:8080/myapp/就可以看到struts2的例子界面了。
?
2. 運(yùn)行一個(gè)webapp目錄
2.1 還是用上面的struts2-blank.war,將這個(gè)war包解壓后放到一個(gè)目錄下;
2.2 創(chuàng)建自己的Jetty Server啟動(dòng)類WebAppContextWithFolderServer,其中指定了webapp目錄,并指定context路徑為"/myapp"
Java代碼???2.3 運(yùn)行WebAppContextWithFolderServer類,然后訪問(wèn)// http://localhost:8080/myapp/就可以看到struts2的例子界面了。
轉(zhuǎn)載于:https://www.cnblogs.com/yangmengdx3/p/4744543.html
總結(jié)
以上是生活随笔為你收集整理的Jetty实战之 嵌入式Jetty运行web app的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: C# indexof和indexofan
- 下一篇: const与#define的异同