本文整理汇总了Java中org.mortbay.jetty.webapp.WebAppContext.addServlet方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.addServlet方法的具体用法?Java WebAppContext.addServlet怎么用?Java WebAppContext.addServlet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.addServlet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWebAppContext
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private static WebAppContext createWebAppContext(String name,
Configuration conf, AccessControlList adminsAcl, final String appDir) {
WebAppContext ctx = new WebAppContext();
ctx.setDefaultsDescriptor(null);
ServletHolder holder = new ServletHolder(new DefaultServlet());
Map<String, String> params = ImmutableMap. <String, String> builder()
.put("acceptRanges", "true")
.put("dirAllowed", "false")
.put("gzip", "true")
.put("useFileMappedBuffer", "true")
.build();
holder.setInitParameters(params);
ctx.setWelcomeFiles(new String[] {"index.html"});
ctx.addServlet(holder, "/");
ctx.setDisplayName(name);
ctx.setContextPath("/");
ctx.setWar(appDir + "/" + name);
ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
addNoCacheFilter(ctx);
return ctx;
}
示例2: main
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Run PRE V. 1.0 in Jetty. Override the EvironmentUtility's set environment depending on what web.xml file is used
* (local or national).
*
* This method expects four command line arguments in the order and type specified. No verification that the arguments
* are valid is done. If improper arguments are set, expect NullPointerExceptions, IOExceptions, String parsing
* exceptions, or that the server started simply does not operate as expected.
*
* @param args [0] (int) port, [1] (String) PRE web.xml file path, [2] (String) FDB Images web application directory
*/
public static void main(String[] args) throws Exception {
Server server = new Server(Integer.parseInt(args[0]));
ApplicationContext context = new ClassPathXmlApplicationContext(
"xml/spring/datup/national/test/InterfaceContext.xml");
DifReportService reportService = (DifReportService) context.getBean("difReportService");
WebAppContext pre = new WebAppContext();
pre.setContextPath(PRE_CONTEXT_PATH);
pre.setWar(PRE_WAR);
// pre.setOverrideDescriptor(args[1]);
ReportServlet reportServlet = new ReportServlet();
reportServlet.setDifReportService(reportService);
pre.addServlet(new ServletHolder(reportServlet), "/datup");
TimerServlet timerServlet = new TimerServlet();
pre.addServlet(new ServletHolder(timerServlet), "/datup/timer");
server.addHandler(pre);
server.start();
System.out.println("Jetty server started on port " + args[0]);
}