jetty 6.2 代码启动
必要jar包
lib --->>
lib--->>jsp2.0--->>
最终形成目录 -->>
mark jetty 6.1 jsp2.1 目录结构
注:由于使用jsp2.1 代码启动时不能对el很好的兼容 不支持三元运算,导致一些表达式抛出elexception 选择了jsp2.0
代码启动很简单:
package com.signheart.imagerotate.server;
import org.junit.Test;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;
public class ServerStart extends Server {
@Test
public void serverStrart() throws Exception {
long begin = System.currentTimeMillis();
Connector connector = new SelectChannelConnector();
connector.setPort(Integer.getInteger("jetty.port", 8888).intValue());
WebAppContext webapp = new WebAppContext("F:/EDev/OA/Code/webapps/OA", "/");
Server server = new Server();
server.setConnectors(new Connector[] { connector });
server.setHandler(webapp);
server.start();
server.join();
System.out.println("Jetty Server started, use " + (System.currentTimeMillis() - begin) + " ms");
}
public void setup() {
}
public void serverStop() throws Exception{
Server server = new Server(8888);
WebAppContext webContext = new WebAppContext("F:/EDev/OA/Code/webapps/OA","/");
server.setHandler(webContext);
server.stop();
}
}