當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletContext.getServletRegistration方法代碼示例

本文整理匯總了Java中javax.servlet.ServletContext.getServletRegistration方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletContext.getServletRegistration方法的具體用法?Java ServletContext.getServletRegistration怎麽用?Java ServletContext.getServletRegistration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.ServletContext的用法示例。


在下文中一共展示了ServletContext.getServletRegistration方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import javax.servlet.ServletContext; //導入方法依賴的package包/類
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    //初始化相關類
    HelperLoader.init();
    //獲取ServletContext對象,注冊Servlet
    ServletContext servletContext = config.getServletContext();
    //處理JSP的Servlet
    ServletRegistration jspServlet = servletContext.getServletRegistration("jsp");
    jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
    //處理靜態資源的默認Servlet
    ServletRegistration defaultServlet = servletContext.getServletRegistration("default");
    defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
}
 
開發者ID:envyandgreed,項目名稱:SmartFramework,代碼行數:15,代碼來源:DispatcherServlet.java

示例2: init

import javax.servlet.ServletContext; //導入方法依賴的package包/類
@Override
public void init(ServletConfig servletConfig) throws ServletException {
	// 初始化相關Helper類
	HelperLoader.init();
	// 獲取ServletContext對象(用於注冊Servlet)
	ServletContext servletContext = servletConfig.getServletContext();
	// 注冊處理jsp的servlet
	ServletRegistration jspServlet = servletContext
			.getServletRegistration("jsp");
	jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
	// 注冊處理靜態資源的默認Servlet
	ServletRegistration defaultServlet = servletContext
			.getServletRegistration("default");
	defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
}
 
開發者ID:longjiazuo,項目名稱:light-framework,代碼行數:16,代碼來源:DispatcherServlet.java

示例3: getServletUrlPattern

import javax.servlet.ServletContext; //導入方法依賴的package包/類
private static String getServletUrlPattern(final ServletContextEvent servletContextEvent) throws Exception {
    final ServletContext servletContext = servletContextEvent.getServletContext();

    ServletRegistration servletRegistration = servletContext.getServletRegistration(servletName);
    if (servletRegistration == null) {
        throw new NoSuchElementException("no servlet with name \"" + servletName + "\" is found.");
    }
    java.util.Collection<java.lang.String> mappings = servletRegistration.getMappings();
    if (mappings.size() != 1) {
        throw new NoSuchElementException("unable to identify servlet mappings for servlet with name \"" + servletName + "\".");
    }
    String mapping = (String) mappings.toArray()[0];

    //url patterns in  most cases end with '\*'. But a url-pattern with just '\' may be found for exact matches.
    if (mapping.endsWith("*"))
        mapping = mapping.substring(0, mapping.length()-1);
    return mapping;
}
 
開發者ID:EricssonResearch,項目名稱:scott-eu,代碼行數:19,代碼來源:ServletListener.java

示例4: registerJspServlet

import javax.servlet.ServletContext; //導入方法依賴的package包/類
private void registerJspServlet(ServletContext context) {
    ServletRegistration servletRegistration = context.getServletRegistration("jsp");
    servletRegistration.addMapping("/index.jsp");
    String jspPath = PropertiesProvider.getString(FrameworkConstant.JSP_PATH);
    if (StringUtil.isNotEmpty(jspPath)) {
    	servletRegistration.addMapping(jspPath + "*");
    }
}
 
開發者ID:smxc,項目名稱:garlicts,代碼行數:9,代碼來源:ContainerListener.java

示例5: registeJspServlet

import javax.servlet.ServletContext; //導入方法依賴的package包/類
/**
 * 添加jsp映射
 */
@Deprecated
private void registeJspServlet(ServletContext context) {
    ServletRegistration jspServlet = context.getServletRegistration("jsp");
    jspServlet.addMapping("/index.jsp");
    String jspPath = Constants.JSP_PATH_VALUE;
    jspServlet.addMapping(jspPath + "*");
}
 
開發者ID:huhuics,項目名稱:tauren,代碼行數:11,代碼來源:Initializer.java

示例6: init

import javax.servlet.ServletContext; //導入方法依賴的package包/類
@Override
public void init(ServletConfig config) throws ServletException {
    Loader.init();//初始化框架&應用
    ServletContext sc = config.getServletContext();
    //注冊JSP的Servlet
    ServletRegistration jspServlet = sc.getServletRegistration("jsp");
    jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
    //注冊處理靜態資源的Servlet
    ServletRegistration defaultServlet = sc.getServletRegistration("default");
    defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
}
 
開發者ID:CFshuming,項目名稱:bfmvc,代碼行數:12,代碼來源:DispatherServlet.java


注:本文中的javax.servlet.ServletContext.getServletRegistration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。