Embeded Jetty with JSP

21ca發表於2017-03-21
Simple Jetty server with JSP supported.
  1.     public static void main(String[] args) throws Exception {
  2.         Server server = new Server(8082);

  3.         Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(server);
  4.         classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
  5.                 "org.eclipse.jetty.annotations.AnnotationConfiguration" );

  6.         WebAppContext context = new WebAppContext("src/main/webapp", "/");
  7.         server.setHandler(context);
  8.         server.start();
  9.     }
pom.xml
  1.       <dependency>
  2.           <groupId>org.eclipse.jetty</groupId>
  3.           <artifactId>apache-jsp</artifactId>
  4.           <version>9.4.2.v20170220</version>
  5.       </dependency>
  6.       <dependency>
  7.           <groupId>org.eclipse.jetty</groupId>
  8.           <artifactId>jetty-annotations</artifactId>
  9.           <version>9.4.2.v20170220</version>
  10.       </dependency>


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10742815/viewspace-2135750/,如需轉載,請註明出處,否則將追究法律責任。

相關文章