我在Jetty中有以下代码:
ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
contextHandler.setContextPath("/a");
ServletHolder holder = new ServletHolder(MyServlet.class);
contextHandler.addServlet(holder, "/b/*");
"/a"
in call tosetContextPath
和"/b/*"
in call to 和有什么不一样addServlet
?这些路径是否连接起来以决定MyServlet
将服务哪些请求?
另外,是否可以将 servlet 与特定的文件扩展名相关联?即,通过查看“ endsWith
”部分,可以说,一个URI 以及以例如“.xsd”结尾的URI 发送到一个特定的Servlet?还是完全基于“ startsWith
”逻辑进行调度?