本文整理汇总了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;
}
示例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;
}