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