本文整理匯總了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() + "*");
}
示例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() + "*");
}
示例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;
}
示例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 + "*");
}
}
示例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 + "*");
}
示例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() + "*");
}