本文整理汇总了Java中org.glassfish.grizzly.servlet.ServletRegistration.setInitParameters方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRegistration.setInitParameters方法的具体用法?Java ServletRegistration.setInitParameters怎么用?Java ServletRegistration.setInitParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.glassfish.grizzly.servlet.ServletRegistration
的用法示例。
在下文中一共展示了ServletRegistration.setInitParameters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _createContext
import org.glassfish.grizzly.servlet.ServletRegistration; //导入方法依赖的package包/类
@Nonnull
private static WebappContext _createContext (final URI u,
final Class <? extends Servlet> aServletClass,
final Servlet aServlet,
final Map <String, String> aInitParams,
final Map <String, String> aContextInitParams)
{
String path = u.getPath ();
if (path == null)
throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be non-null");
if (path.isEmpty ())
throw new IllegalArgumentException ("The URI path, of the URI " + u + ", must be present");
if (path.charAt (0) != '/')
throw new IllegalArgumentException ("The URI path, of the URI " + u + ". must start with a '/'");
path = String.format ("/%s", UriComponent.decodePath (u.getPath (), true).get (1).toString ());
final WebappContext aContext = new WebappContext ("GrizzlyContext", path);
ServletRegistration registration;
if (aServletClass != null)
registration = aContext.addServlet (aServletClass.getName (), aServletClass);
else
registration = aContext.addServlet (aServlet.getClass ().getName (), aServlet);
registration.addMapping ("/*");
if (aContextInitParams != null)
for (final Map.Entry <String, String> e : aContextInitParams.entrySet ())
aContext.setInitParameter (e.getKey (), e.getValue ());
if (aInitParams != null)
registration.setInitParameters (aInitParams);
return aContext;
}
示例2: registerServlet
import org.glassfish.grizzly.servlet.ServletRegistration; //导入方法依赖的package包/类
private void registerServlet(final WebappContext webapp) {
ServletRegistration registration = webapp.addServlet(servlet.getSimpleName(), servlet);
registration.addMapping(mapping);
registration.setInitParameters(initParameters);
registration.setLoadOnStartup(1);
}