<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>7.2.2.v20101205</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-glassfish</artifactId>
<version>2.1.v20100127</version>
</dependency>
鍒涘緩涓涓猨ava綾伙細
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class GameAdmin {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Server server = buildNormalServer(8080, "/gameweb");
server.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 鍒涘緩鐢ㄤ簬姝e父榪愯璋冭瘯鐨凧etty Server, 浠rc/main/webapp涓篧eb搴旂敤鐩綍.
*/
public static Server buildNormalServer(int port, String contextPath) {
Server server = new Server(port);
WebAppContext webContext = new WebAppContext("src/main/webapp", contextPath);
webContext.setClassLoader(Thread.currentThread().getContextClassLoader());
server.setHandler(webContext);
server.setStopAtShutdown(true);
return server;
}
}

]]>