jetty 6.1 笔记




jetty 6.2 代码启动

必要jar包

lib --->>

lib--->>jsp2.0--->> 


最终形成目录 -->>


mark jetty 6.1  jsp2.1 目录结构


注:由于使用jsp2.1 代码启动时不能对el很好的兼容 不支持三元运算,导致一些表达式抛出elexception 选择了jsp2.0

代码启动很简单:

  1. package com.signheart.imagerotate.server;
  2. import org.junit.Test;
  3. import org.mortbay.jetty.Connector;
  4. import org.mortbay.jetty.Server;
  5. import org.mortbay.jetty.nio.SelectChannelConnector;
  6. import org.mortbay.jetty.webapp.WebAppContext;
  7. public class ServerStart extends Server {
  8. @Test
  9. public void serverStrart() throws Exception {
  10. long begin = System.currentTimeMillis();
  11. Connector connector = new SelectChannelConnector();
  12. connector.setPort(Integer.getInteger("jetty.port", 8888).intValue());
  13. WebAppContext webapp = new WebAppContext("F:/EDev/OA/Code/webapps/OA", "/");
  14. Server server = new Server();
  15. server.setConnectors(new Connector[] { connector });
  16. server.setHandler(webapp);
  17. server.start();
  18. server.join();
  19. System.out.println("Jetty Server started, use " + (System.currentTimeMillis() - begin) + " ms");
  20. }
  21. public void setup() {
  22. }
  23. public void serverStop() throws Exception{
  24. Server server = new Server(8888);
  25. WebAppContext webContext = new WebAppContext("F:/EDev/OA/Code/webapps/OA","/");
  26. server.setHandler(webContext);
  27. server.stop();
  28. }
  29. }







posted on 2017-03-24 08:52  signheart  阅读(730)  评论(0编辑  收藏  举报

导航