jetty 官网 :http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html#d0e19086


import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.NCSARequestLog;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.RequestLogHandler;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
Server server = new Server();SelectChannelConnector connector = new SelectChannelConnector();connector.setPort(port);connector.setMaxIdleTime(300000);// 10Mconnector.setRequestHeaderSize(1024 * 1024 * 10);connector.setThreadPool(new QueuedThreadPool(20));connector.setName("jetty");server.addConnector(connector);ContextHandler context = new ContextHandler();context.setContextPath("/");context.setResourceBase(".");context.setClassLoader(Thread.currentThread().getContextClassLoader());server.setHandler(context);HandlerList handlers = new HandlerList();try {RequestLogHandler classPathLog = new RequestLogHandler();String classPath = "" ;try {//class pathclassPath = this.getClass().getResource("/").getPath() ;File logFile = new File(classPath+File.separatorChar+"jetty.log") ;classPathLog.setRequestLog( new NCSARequestLog(logFile.getAbsolutePath()) ) ;} catch (Exception e) {System.err.println( "Can not create log in the "+classPath);}handlers.setHandlers(new Handler[] { classPathLog });  // set handler ,deal with the request   context.setHandler(handlers);context.setHandler(handlers);server.start();

Embeded Jetty相关推荐

  1. idea(3)-jetty配置

    1.jetty&jdk版本 9.3----->1.8 9.2----->1.7 8------->1.6 2.pom.xml <plugin><groupI ...

  2. 怎么将jenkins打包后的war自动部署到jetty上?

    1,使用maven的cargo插件,实现远程部署 (官网描述地址:https://codehaus-cargo.github.io/cargo/Jetty+Remote+Deployer.html) ...

  3. Jetty Cross Origin Filter解决jQuery Ajax跨域访问的方法

    当使用jQuery Ajax post请求时可能会遇到类似这样的错误提示 XMLHttpRequest cannot load http://xxxxxx. Origin http://xxxxxx ...

  4. 【转】Maven Jetty 插件的问题(css/js等目录死锁)的解决

    Maven Jetty 插件的问题(css/js等目录死锁,不能自动刷新)的解决: 1. 打开下面的目录:C:\Users\用户名\.m2\repository\org\eclipse\jetty\j ...

  5. 深入Jetty源码之Servlet框架及实现(AsyncContext、RequestDispatcher、HttpSession)

    概述 Servlet是Server Applet的缩写,即在服务器端运行的小程序,而Servlet框架则是对HTTP服务器(Servlet Container)和用户小程序中间层的标准化和抽象.这一层 ...

  6. idea下,Jetty采用main方法启动web项目

    为什么80%的码农都做不了架构师?>>>    对于maven多模块的spring web项目,本地开发时,启动的方式一般有如下几种: 使用容器(tomcat/jetty/resin ...

  7. atitit.跨架构 bs cs解决方案. 自定义web服务器的实现方案 java .net jetty  HttpListener...

    atitit.跨架构 bs cs解决方案. 自定义web服务器的实现方案 java .net jetty  HttpListener 1. 自定义web服务器的实现方案,基于原始socket vs   ...

  8. Eclipse Jetty 9.4.15 发布,建议使用 JDK 12

    Eclipse Jetty 9.4.15 发布了,此版本包含大量的 bug 修复和改进,要点: Java 11 有一个有问题的 TLS 实现.目前 Jetty 团队建议使用 JDK 12,直到 JDK ...

  9. IDEA下使用Jetty进行Debug模式调试【含演示GIF图】

    2019独角兽企业重金招聘Python工程师标准>>> 步骤 在web项目中配置jetty: <plugin><groupId>org.eclipse.jet ...

最新文章

  1. Go 分布式学习利器(17)-- Go并发编程之协程机制:Grountine 原理及使用
  2. 2018-3-19 损失函数与适应度函数,稳定选择与分裂选择
  3. mongodb自动关闭:页面太小,无法完成操作
  4. 链表相交以及找循环链表入口
  5. 使用python 实现icmp测试主机存活性
  6. python框架之Django(2)-简单的CRUD
  7. RabbitMQ——无法连接错误[AmqpConnectException: java.net.ConnectException: Connection refused: connect]解决方案
  8. vba 当前文件名_VBA代码解决方案第77讲内容:如何导出文件
  9. Java——集合(练习题)
  10. linux 常用命令02--文件属性 以及软硬链接
  11. HBase的RowKey设计
  12. iOS开发之保存照片到自己创建的相簿
  13. for循环里面嵌套if_信不信两层python嵌套for循环就能把你搞懵了
  14. vue组件化学习第一天
  15. 我的web前端工作日记2------web前端工作的一天
  16. 命令方块召唤别墅指令_我的世界:如何在MC召唤实体303?告示牌的数字,才是关键!...
  17. 华为有哪些高科技技术?
  18. java面试题,输入一串数字,输出大写金额,如123 输出壹佰贰拾叁整。
  19. 从 java 8 到 java 17
  20. [附源码]Python计算机毕业设计Django儿童早教课程管理系统论文2022

热门文章

  1. 怎么把PDF文件转换成图片?分享三个方法
  2. cfc 教程_Google CFC
  3. 到底什么是新媒体、什么是互动、什么是互动营销?
  4. springboot中使用人大金仓
  5. 孟晚舟归国后首次亮相:一语道出华为真正价值!唯有努力才能赶上祖国变化...
  6. 【家庭推】日历苹果群发软件imessage查看docker消息
  7. 视频教程-Project-管理项目(进阶)-Office/WPS
  8. rtmp 播放h265 (rtmp 播放hevc)
  9. 数据筛选与处理AWK
  10. 入门学习:网络营销的新手们,赶紧来了解一下吧!