本文整理匯總了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]);
}