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


Java ServletUtil.getContainer方法代碼示例

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


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

示例1: checkResource

import org.apache.tiles.servlet.context.ServletUtil; //導入方法依賴的package包/類
@Override
public boolean checkResource(final Locale locale) throws Exception {
	TilesContainer container = ServletUtil.getContainer(getServletContext());
	if (!(container instanceof BasicTilesContainer)) {
		// Cannot check properly - let's assume it's there.
		return true;
	}
	BasicTilesContainer basicContainer = (BasicTilesContainer) container;
	TilesApplicationContext appContext = new ServletTilesApplicationContext(getServletContext());
	TilesRequestContext requestContext = new ServletTilesRequestContext(appContext, null, null) {
		@Override
		public Locale getRequestLocale() {
			return locale;
		}
	};
	return (basicContainer.getDefinitionsFactory().getDefinition(getUrl(), requestContext) != null);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:TilesView.java

示例2: renderMergedOutputModel

import org.apache.tiles.servlet.context.ServletUtil; //導入方法依賴的package包/類
@Override
protected void renderMergedOutputModel(
		Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

	ServletContext servletContext = getServletContext();
	TilesContainer container = ServletUtil.getContainer(servletContext);
	if (container == null) {
		throw new ServletException("Tiles container is not initialized. " +
				"Have you added a TilesConfigurer to your web application context?");
	}

	exposeModelAsRequestAttributes(model, request);
	JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext));
	if (this.alwaysInclude) {
		ServletUtil.setForceInclude(request, true);
	}
	container.render(getUrl(), request, response);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:19,代碼來源:TilesView.java

示例3: simpleBootstrap

import org.apache.tiles.servlet.context.ServletUtil; //導入方法依賴的package包/類
@Test
@SuppressWarnings("deprecation")
public void simpleBootstrap() {
	MockServletContext sc = new MockServletContext();
	TilesConfigurer tc = new TilesConfigurer();
	tc.setDefinitions("/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml");
	tc.setCheckRefresh(true);
	tc.setServletContext(sc);
	tc.afterPropertiesSet();

	BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getContainer(sc);
	TilesRequestContext requestContext = new ServletTilesRequestContext(
			container.getApplicationContext(), new MockHttpServletRequest(), new MockHttpServletResponse());
	assertNotNull(container.getDefinitionsFactory().getDefinition("test", requestContext));

	tc.destroy();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:TilesConfigurerTests.java

示例4: simpleBootstrap

import org.apache.tiles.servlet.context.ServletUtil; //導入方法依賴的package包/類
@Test
public void simpleBootstrap() {
	MockServletContext sc = new MockServletContext();
	TilesConfigurer tc = new TilesConfigurer();
	tc.setDefinitions("/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml");
	tc.setCheckRefresh(true);
	tc.setServletContext(sc);
	tc.afterPropertiesSet();

	BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getContainer(sc);
	TilesRequestContext requestContext = new ServletTilesRequestContext(
			container.getApplicationContext(), new MockHttpServletRequest(), new MockHttpServletResponse());
	assertNotNull(container.getDefinitionsFactory().getDefinition("test", requestContext));

	tc.destroy();
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:17,代碼來源:TilesConfigurerTests.java

示例5: renderMergedOutputModel

import org.apache.tiles.servlet.context.ServletUtil; //導入方法依賴的package包/類
@Override
protected void renderMergedOutputModel(
		Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

	ServletContext servletContext = getServletContext();
	TilesContainer container = ServletUtil.getContainer(servletContext);
	if (container == null) {
		throw new ServletException("Tiles container is not initialized. " +
				"Have you added a TilesConfigurer to your web application context?");
	}

	exposeModelAsRequestAttributes(model, request);
	JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext));

	if (!response.isCommitted()) {
		// Tiles is going to use a forward, but some web containers (e.g. OC4J 10.1.3)
		// do not properly expose the Servlet 2.4 forward request attributes... However,
		// must not do this on Servlet 2.5 or above, mainly for GlassFish compatibility.
		if (this.exposeForwardAttributes) {
			try {
				WebUtils.exposeForwardRequestAttributes(request);
			}
			catch (Exception ex) {
				// Servlet container rejected to set internal attributes, e.g. on TriFork.
				this.exposeForwardAttributes = false;
			}
		}
	}

	container.render(getUrl(), request, response);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:32,代碼來源:TilesView.java


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