当前位置: 首页>>代码示例>>Java>>正文


Java Arguments.getContext方法代码示例

本文整理汇总了Java中org.thymeleaf.Arguments.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java Arguments.getContext方法的具体用法?Java Arguments.getContext怎么用?Java Arguments.getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.thymeleaf.Arguments的用法示例。


在下文中一共展示了Arguments.getContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isVisible

import org.thymeleaf.Arguments; //导入方法依赖的package包/类
@Override
protected boolean isVisible(final Arguments arguments, final Element element, final String attributeName) {

    String attributeValue = element.getAttributeValue(attributeName);

    if (StringUtils.indexOf(attributeValue, "isAdminPage") != -1) {
        Object context = arguments.getContext();
        if (context instanceof SpringWebContext) {
            SpringWebContext webContext = (SpringWebContext) context;
            HttpServletRequest httpServletRequest = webContext.getHttpServletRequest();
            boolean val = StringUtils.indexOf(httpServletRequest.getRequestURI(), "/_admin/") != -1;
            attributeValue = StringUtils.replace(attributeValue, "isAdminPage", Boolean.toString(val));
        }
    }

    final Configuration configuration = arguments.getConfiguration();
    final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);

    final IStandardExpression expression = expressionParser.parseExpression(configuration, arguments, attributeValue);
    final Object value = expression.execute(configuration, arguments);

    final boolean visible = EvaluationUtil.evaluateAsBoolean(value);

    return visible;
}
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:26,代码来源:MyFunctionDialect.java

示例2: getBundleUrl

import org.thymeleaf.Arguments; //导入方法依赖的package包/类
/**
 * Adds the context path to the bundleUrl.    We don't use the Thymeleaf "@" syntax or any other mechanism to 
 * encode this URL as the resolvers could have a conflict.   
 * 
 * For example, resolving a bundle named "style.css" that has a file also named "style.css" creates problems as
 * the TF or version resolvers both want to version this file.
 *  
 * @param arguments
 * @param bundleName
 * @return
 */
protected String getBundleUrl(Arguments arguments, String bundleName) {
    String bundleUrl = bundleName;

    if (!StringUtils.startsWith(bundleUrl, "/")) {
        bundleUrl = "/" + bundleUrl;
    }

    IWebContext context = (IWebContext) arguments.getContext();
    HttpServletRequest request = context.getHttpServletRequest();
    String contextPath = request.getContextPath();

    if (StringUtils.isNotEmpty(contextPath)) {
        bundleUrl = contextPath + bundleUrl;
    }

    return bundleUrl;
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:29,代码来源:ResourceBundleProcessor.java


注:本文中的org.thymeleaf.Arguments.getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。