小编Abd*_*aif的帖子

如何配置多个 Jetty 处理程序?

我在为 Web 应用程序设置处理程序时遇到问题,我想要的是:通过 withHTTPServletdoGet方法处理一些请求doPost(如何从这些方法中加载 JSP 页面?)并且还能够加载静态内容(html、JS、CSS)。

我现在的设置方式,只能选择其中之一,无法同时使用。

我会解释:

Server server = new Server(5000);

// This is the resource handler for JS & CSS

ResourceHandler resourceHandler = new ResourceHandler();

resourceHandler.setResourceBase(".");

resourceHandler.setDirectoriesListed(false);

// This is the context handler for the HTTPServlet

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

context.setContextPath("/");

context.addServlet(new ServletHolder(new Main()),"/*");

// this is the Handler list for both handlers

HandlerList handlerList = new HandlerList();

handlerList.setHandlers(new Handler[] { context ,resourceHandler});

/*

   If I add them in this …
Run Code Online (Sandbox Code Playgroud)

java jsp jetty handler

1
推荐指数
1
解决办法
4174
查看次数

标签 统计

handler ×1

java ×1

jetty ×1

jsp ×1