![](/img/trans.png)
[英]Is there a way to set context-params programmatically in embedded jetty?
[英]Possible to set context valve and realm programmatically using embedded jetty?
我正在按照以下步驟設置嵌入式Jetty服務器:
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
ServletHandler handler = new ServletHandler();
context.addServlet(new ServletHolder(new CustomServlet()),"/*");
context.setHandler(handler);
server.setHandler(context);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
我想以編程方式添加以下參數。
<Context>
<Valve className="a.ClassA" />
<Realm className="b.ClassB" />
</Context>
我怎樣才能做到這一點?
在Java本身上,jetty xml只是一個皮膚,因此您可以在嵌入式xml中執行的所有操作都可以在jetty xml中進行。
這是我們嵌入碼頭的文檔的鏈接。
http://www.eclipse.org/jetty/documentation/current/advanced-embedding.html
對我來說,目前尚不清楚您要在這里做什么,但是以下示例對安全領域等進行了一些說明。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.