本文整理匯總了Java中org.apache.tiles.servlet.context.ServletUtil類的典型用法代碼示例。如果您正苦於以下問題:Java ServletUtil類的具體用法?Java ServletUtil怎麽用?Java ServletUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ServletUtil類屬於org.apache.tiles.servlet.context包,在下文中一共展示了ServletUtil類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例6: destroy
import org.apache.tiles.servlet.context.ServletUtil; //導入依賴的package包/類
/**
* Removes the TilesContainer from this web application.
* @throws TilesException in case of cleanup failure
*/
public void destroy() throws TilesException {
try {
// Tiles 2.2?
ReflectionUtils.invokeMethod(TilesInitializer.class.getMethod("destroy"), this.tilesInitializer);
}
catch (NoSuchMethodException ex) {
// Tiles 2.1...
ServletUtil.setContainer(this.servletContext, null);
}
}
示例7: CmmntyTilesPage
import org.apache.tiles.servlet.context.ServletUtil; //導入依賴的package包/類
/**
* 커뮤니티 타일 페이지로 이동한다.
*
*/
@RequestMapping("/cop/cmy/CmmntyTilesPage.do")
public String CmmntyTilesPage(
HttpServletRequest request,
HttpServletResponse response,
ModelMap model)
throws Exception {
String jspPage = (String) request.getAttribute("jspPage");
String cmmntyId = (String) request.getAttribute("curTrgetId");
String menuId = (String) request.getAttribute("curMenuNo");
if (!cmmntyId.startsWith("CMMNTY_") || "".equals(menuId)) {
return jspPage;
}
CommunityVO communityVO = cmmntyService.getCommunityInfo(cmmntyId, menuId);
model.addAttribute("targetVO", communityVO);
// --------------------------------
// 커뮤니티 사용자 정보
// --------------------------------
model.addAttribute("targetUserVO", cmmntyService.getCommunityUserInfo(cmmntyId));
// --------------------------------
// 메뉴 정보
// --------------------------------
String menuAlias = getMenuInfo(communityVO, menuId, "menuAlias");
if( "".equals(menuAlias) ) {
menuAlias = communityVO.getTopMenuList().get(0).get("menuAlias").toString();
}
model.addAttribute("menuAlias", menuAlias);
// --------------------------------
// 커뮤니티 템플릿 정보
// --------------------------------
String tmplatCours = cmmntyService.selectCmmntyTemplat(communityVO);
if ("".equals(tmplatCours) || tmplatCours == null) {
tmplatCours = "/WEB-INF/layouts/apps/appsDefault";
}
TilesContainer container = ServletUtil.getCurrentContainer(request, request.getSession().getServletContext());
AttributeContext attributeContext = container.startContext(request, response);
if (tmplatCours.indexOf("/WEB-INF/layouts") != -1) {
attributeContext.setTemplateAttribute(new Attribute(tmplatCours+".jsp"));
} else {
attributeContext.setTemplateAttribute(new Attribute("/WEB-INF/jsp/"+tmplatCours+".jsp"));
}
return jspPage;
}