本文整理汇总了Java中org.eclipse.jetty.servlet.ServletMapping.setPathSpecs方法的典型用法代码示例。如果您正苦于以下问题:Java ServletMapping.setPathSpecs方法的具体用法?Java ServletMapping.setPathSpecs怎么用?Java ServletMapping.setPathSpecs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.ServletMapping
的用法示例。
在下文中一共展示了ServletMapping.setPathSpecs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeServlet
import org.eclipse.jetty.servlet.ServletMapping; //导入方法依赖的package包/类
/**
* Removes the previously registered servlet from the specified path
*
* @param pathSpec
* the path spec to remove
* @throws WebServerException
* if an error occurs
*/
public synchronized static void removeServlet(String pathSpec) throws WebServerException {
if (contexts != null) {
try {
ServletHandler handler = contexts.getServletHandler();
List<ServletMapping> mappings = new ArrayList<>();
for (ServletMapping mapping : handler.getServletMappings()) {
List<String> pathSpecs = new ArrayList<>();
for (String path : mapping.getPathSpecs()) {
if (!pathSpec.equals(path)) {
pathSpecs.add(path);
}
}
if (!pathSpecs.isEmpty()) {
mapping.setPathSpecs(pathSpecs.toArray(new String[pathSpecs.size()]));
mappings.add(mapping);
}
}
handler.setServletMappings(mappings.toArray(new ServletMapping[mappings.size()]));
} catch (Exception e) {
throw new WebServerException(e);
}
}
}
示例2: addJspServlet
import org.eclipse.jetty.servlet.ServletMapping; //导入方法依赖的package包/类
/**
* Add Jetty's {@code JspServlet} to the given {@link WebAppContext}.
* @param context the jetty {@link WebAppContext}
*/
protected final void addJspServlet(WebAppContext context) {
Assert.notNull(context, "Context must not be null");
ServletHolder holder = new ServletHolder();
holder.setName("jsp");
holder.setClassName(getJspServlet().getClassName());
holder.setInitParameter("fork", "false");
holder.setInitParameters(getJspServlet().getInitParameters());
holder.setInitOrder(3);
context.getServletHandler().addServlet(holder);
ServletMapping mapping = new ServletMapping();
mapping.setServletName("jsp");
mapping.setPathSpecs(new String[] { "*.jsp", "*.jspx" });
context.getServletHandler().addServletMapping(mapping);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:JettyEmbeddedServletContainerFactory.java
示例3: deployServlet
import org.eclipse.jetty.servlet.ServletMapping; //导入方法依赖的package包/类
public synchronized void deployServlet(HttpServlet servlet, Map<String, String> initParams, String... paths)
{
ServletHolder holder = new ServletHolder(servlet);
if (initParams != null)
holder.setInitParameters(initParams);
ServletMapping mapping = new ServletMapping();
mapping.setServletName(holder.getName());
mapping.setPathSpecs(paths);
servletHandler.getServletHandler().addServlet(holder);
servletHandler.getServletHandler().addServletMapping(mapping);
log.debug("Servlet deployed " + mapping.toString());
}