Tag - web容器

java jetty web容器    2017-07-19 23:32:47    867
1、准备好一个非常简单点的web项目(maven项目)
2、准备好maven环境,并配置pom文件,关于jetty内容如下:
  1. <!-- jetty dependecies begin -->
  2.   <dependency>
  3.    <groupId>org.eclipse.jetty</groupId>
  4.    <artifactId>jetty-server</artifactId>
  5.    <version>9.1.4.v20140401</version>
  6.   </dependency>
  7.  
  8.   <dependency>
  9.    <groupId>org.eclipse.jetty</groupId>
  10.    <artifactId>jetty-webapp</artifactId>
  11.    <version>9.1.4.v20140401</version>
  12.   </dependency>
  13.  
  14.   <dependency>
  15.    <groupId>org.eclipse.jetty</groupId>
  16.    <artifactId>jetty-continuation</artifactId>
  17.    <version>9.1.4.v20140401</version>
  18.   </dependency>
  19.  
  20.   <dependency>
  21.    <groupId>org.eclipse.jetty</groupId>
  22.    <artifactId>jetty-jsp</artifactId>
  23.    <version>9.1.4.v20140401</version>
  24.   </dependency>
  25.   <!-- jetty dependecies end -->

3、使用eclipse对maven项目进行build,获取build后的项目目录(或者将项目达成war包)

4、创建运行配置jetty的Server类
    运行war包的类
  1. public class WebAppWarServer {
  2.  public static void main(String[] args) throws Exception {
  3.   Server server = new Server(8080);
  4.  
  5.   WebAppContext context = new WebAppContext();
  6.   contex