servlet之ServletContext和ServletRegistration

1、ServletContext

(1)Servlet三大域对象的应用 request、session、application(ServletContext);

(2) String path = context.getContextPath(); //获取上下文路径

2、ServletRegistration注册区域,可以添加路径

	ServletRegistration defaultServlet = context.getServletRegistration("default");
		defaultServlet.addMapping("/index.html");
		defaultServlet.addMapping("/favicon.ico");
		String wwwPath = FrameworkConstant.WWW_PATH;
		if (StringUtil.isNotEmpty(wwwPath)) {
			defaultServlet.addMapping(wwwPath + "*");
		}

猜你喜欢

转载自my.oschina.net/u/3847203/blog/1814401
今日推荐