org.eclipse.jetty.servlet.ServletHandler.getServletMapping()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.eclipse.jetty.servlet.ServletHandler.getServletMapping()方法的一些代码示例,展示了ServletHandler.getServletMapping()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ServletHandler.getServletMapping()方法的具体详情如下:
包路径:org.eclipse.jetty.servlet.ServletHandler
类名称:ServletHandler
方法名:getServletMapping

ServletHandler.getServletMapping介绍

[英]Get the ServletMapping matching the path
[中]获取与路径匹配的ServletMapping

代码示例

代码示例来源:origin: org.springframework.boot/spring-boot

/**
 * Add Jetty's {@code DefaultServlet} to the given {@link WebAppContext}.
 * @param context the jetty {@link WebAppContext}
 */
protected final void addDefaultServlet(WebAppContext context) {
  Assert.notNull(context, "Context must not be null");
  ServletHolder holder = new ServletHolder();
  holder.setName("default");
  holder.setClassName("org.eclipse.jetty.servlet.DefaultServlet");
  holder.setInitParameter("dirAllowed", "false");
  holder.setInitOrder(1);
  context.getServletHandler().addServletWithMapping(holder, "/");
  context.getServletHandler().getServletMapping("/").setDefault(true);
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

ServletMapping servlet_mapping =_servletHandler.getServletMapping("*.jsp");
if (servlet_mapping!=null)
ServletMapping default_mapping=_servletHandler.getServletMapping("/");
if (default_mapping!=null)
  dft_name=default_mapping.getServletName();

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

ServletMapping servlet_mapping =_servletHandler.getServletMapping("*.jsp");
if (servlet_mapping!=null)
ServletMapping default_mapping=_servletHandler.getServletMapping("/");
if (default_mapping!=null)
  dft_name=default_mapping.getServletName();

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.servlet

updateMappings();        
if (getServletMapping("/")==null && _ensureDefaultServlet)
  addServletWithMapping(Default404Servlet.class,"/");
  updateMappings();  
  getServletMapping("/").setDefault(true);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.servlet

ServletMapping servlet_mapping =_servletHandler.getServletMapping("*.jsp");
if (servlet_mapping!=null)
ServletMapping default_mapping=_servletHandler.getServletMapping("/");
if (default_mapping!=null)
  dft_name=default_mapping.getServletName();

代码示例来源:origin: Nextdoor/bender

updateMappings();        
if (getServletMapping("/")==null && _ensureDefaultServlet)
  addServletWithMapping(Default404Servlet.class,"/");
  updateMappings();  
  getServletMapping("/").setDefault(true);

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

ServletMapping servlet_mapping =_servletHandler.getServletMapping("*.jsp");
if (servlet_mapping!=null)
ServletMapping default_mapping=_servletHandler.getServletMapping("/");
if (default_mapping!=null)
  dft_name=default_mapping.getServletName();

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

for (String pattern : urlPatterns)
  ServletMapping mapping = _servletHandler.getServletMapping(pattern);
  if (mapping!=null)

代码示例来源:origin: Nextdoor/bender

ServletMapping servlet_mapping =_servletHandler.getServletMapping("*.jsp");
if (servlet_mapping!=null)
ServletMapping default_mapping=_servletHandler.getServletMapping("/");
if (default_mapping!=null)
  dft_name=default_mapping.getServletName();

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

for (String pattern : urlPatterns)
  ServletMapping mapping = _servletHandler.getServletMapping(pattern);
  if (mapping!=null)

代码示例来源:origin: jenkinsci/winstone

ServletMapping servlet_mapping =_servletHandler.getServletMapping("*.jsp");
if (servlet_mapping!=null)
ServletMapping default_mapping=_servletHandler.getServletMapping("/");
if (default_mapping!=null)
  dft_name=default_mapping.getServletName();

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

for (String pattern : urlPatterns)
  ServletMapping mapping = _servletHandler.getServletMapping(pattern);
  if (mapping!=null)

代码示例来源:origin: org.sonatype.http-testing-harness/server-provider

public void addServlet(String pathSpec, ServletHolder servletHolder) {
 if (webappContext == null) {
  try {
   initServer();
  }
  catch (Exception e) {
   throw new IllegalStateException(e);
  }
 }
 // Jetty 9.2 is sensitive to overlapping mappings, so remove it pathSpec already exists
 if (webappContext.getServletHandler().getServletMapping(pathSpec) != null) {
  final ServletMapping[] servletMappings = webappContext.getServletHandler().getServletMappings();
  final String oldServletName = webappContext.getServletHandler().getServletMapping(pathSpec).getServletName();
  ServletMapping oldServletMapping = null;
  for (ServletMapping servletMapping : servletMappings) {
   if (servletMapping.getServletName().equals(oldServletName)) {
    oldServletMapping = servletMapping;
    break;
   }
  }
  final ServletMapping[] servletMappingsOldRemoved = ArrayUtil.removeFromArray(servletMappings, oldServletMapping);
  webappContext.getServletHandler().setServletMappings(servletMappingsOldRemoved);
 }
 webappContext.getServletHandler().addServletWithMapping(servletHolder, pathSpec);
}

代码示例来源:origin: Nextdoor/bender

@Override
public Set<String> addMapping(String... urlPatterns)
{
  illegalStateIfContextStarted();
  Set<String> clash=null;
  for (String pattern : urlPatterns)
  {
    ServletMapping mapping = _servletHandler.getServletMapping(pattern);
    if (mapping!=null)
    {
      //if the servlet mapping was from a default descriptor, then allow it to be overridden
      if (!mapping.isDefault())
      {
        if (clash==null)
          clash=new HashSet<String>();
        clash.add(pattern);
      }
    }
  }
  //if there were any clashes amongst the urls, return them
  if (clash!=null)
    return clash;
  //otherwise apply all of them
  ServletMapping mapping = new ServletMapping();
  mapping.setServletName(ServletHolder.this.getName());
  mapping.setPathSpecs(urlPatterns);
  _servletHandler.addServletMapping(mapping);
  return Collections.emptySet();
}

代码示例来源:origin: org.sonatype.goodies/goodies-httpfixture

public void addServlet(String pathSpec, ServletHolder servletHolder) {
 if (webappContext == null) {
  try {
   initServer();
  }
  catch (Exception e) {
   throw new IllegalStateException(e);
  }
 }
 // Jetty 9.2 is sensitive to overlapping mappings, so remove it pathSpec already exists
 if (webappContext.getServletHandler().getServletMapping(pathSpec) != null) {
  final ServletMapping[] servletMappings = webappContext.getServletHandler().getServletMappings();
  final String oldServletName = webappContext.getServletHandler().getServletMapping(pathSpec).getServletName();
  ServletMapping oldServletMapping = null;
  for (ServletMapping servletMapping : servletMappings) {
   if (servletMapping.getServletName().equals(oldServletName)) {
    oldServletMapping = servletMapping;
    break;
   }
  }
  final ServletMapping[] servletMappingsOldRemoved = ArrayUtil.removeFromArray(servletMappings, oldServletMapping);
  webappContext.getServletHandler().setServletMappings(servletMappingsOldRemoved);
 }
 webappContext.getServletHandler().addServletWithMapping(servletHolder, pathSpec);
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

@Override
public Set<String> addMapping(String... urlPatterns)
{
  illegalStateIfContextStarted();
  Set<String> clash=null;
  for (String pattern : urlPatterns)
  {
    ServletMapping mapping = _servletHandler.getServletMapping(pattern);
    if (mapping!=null)
    {
      //if the servlet mapping was from a default descriptor, then allow it to be overridden
      if (!mapping.isDefault())
      {
        if (clash==null)
          clash=new HashSet<String>();
        clash.add(pattern);
      }
    }
  }
  //if there were any clashes amongst the urls, return them
  if (clash!=null)
    return clash;
  //otherwise apply all of them
  ServletMapping mapping = new ServletMapping();
  mapping.setServletName(ServletHolder.this.getName());
  mapping.setPathSpecs(urlPatterns);
  _servletHandler.addServletMapping(mapping);
  return Collections.emptySet();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.servlet

@Override
public Set<String> addMapping(String... urlPatterns)
{
  illegalStateIfContextStarted();
  Set<String> clash=null;
  for (String pattern : urlPatterns)
  {
    ServletMapping mapping = _servletHandler.getServletMapping(pattern);
    if (mapping!=null)
    {
      //if the servlet mapping was from a default descriptor, then allow it to be overridden
      if (!mapping.isDefault())
      {
        if (clash==null)
          clash=new HashSet<String>();
        clash.add(pattern);
      }
    }
  }
  //if there were any clashes amongst the urls, return them
  if (clash!=null)
    return clash;
  //otherwise apply all of them
  ServletMapping mapping = new ServletMapping();
  mapping.setServletName(ServletHolder.this.getName());
  mapping.setPathSpecs(urlPatterns);
  _servletHandler.addServletMapping(mapping);
  return Collections.emptySet();
}

代码示例来源:origin: jenkinsci/winstone

@Override
public Set<String> addMapping(String... urlPatterns)
{
  illegalStateIfContextStarted();
  Set<String> clash=null;
  for (String pattern : urlPatterns)
  {
    ServletMapping mapping = _servletHandler.getServletMapping(pattern);
    if (mapping!=null)
    {
      //if the servlet mapping was from a default descriptor, then allow it to be overridden
      if (!mapping.isDefault())
      {
        if (clash==null)
          clash=new HashSet<String>();
        clash.add(pattern);
      }
    }
  }
  //if there were any clashes amongst the urls, return them
  if (clash!=null)
    return clash;
  //otherwise apply all of them
  ServletMapping mapping = new ServletMapping(Source.JAVAX_API);
  mapping.setServletName(ServletHolder.this.getName());
  mapping.setPathSpecs(urlPatterns);
  _servletHandler.addServletMapping(mapping);
  return Collections.emptySet();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

@Override
public Set<String> addMapping(String... urlPatterns)
{
  illegalStateIfContextStarted();
  Set<String> clash=null;
  for (String pattern : urlPatterns)
  {
    ServletMapping mapping = _servletHandler.getServletMapping(pattern);
    if (mapping!=null)
    {
      //if the servlet mapping was from a default descriptor, then allow it to be overridden
      if (!mapping.isDefault())
      {
        if (clash==null)
          clash=new HashSet<String>();
        clash.add(pattern);
      }
    }
  }
  //if there were any clashes amongst the urls, return them
  if (clash!=null)
    return clash;
  //otherwise apply all of them
  ServletMapping mapping = new ServletMapping();
  mapping.setServletName(ServletHolder.this.getName());
  mapping.setPathSpecs(urlPatterns);
  _servletHandler.addServletMapping(mapping);
  return Collections.emptySet();
}

代码示例来源:origin: jenkinsci/winstone

updateMappings();        
if (getServletMapping("/")==null && isEnsureDefaultServlet())
  addServletWithMapping(Default404Servlet.class,"/");
  updateMappings();  
  getServletMapping("/").setDefault(true);

相关文章

微信公众号

最新文章

更多

ServletHandler类方法