本文整理汇总了Java中org.thymeleaf.spring4.context.SpringWebContext类的典型用法代码示例。如果您正苦于以下问题:Java SpringWebContext类的具体用法?Java SpringWebContext怎么用?Java SpringWebContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpringWebContext类属于org.thymeleaf.spring4.context包,在下文中一共展示了SpringWebContext类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isVisible
import org.thymeleaf.spring4.context.SpringWebContext; //导入依赖的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: getModifiedAttributeValues
import org.thymeleaf.spring4.context.SpringWebContext; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
String href = "#";
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
AdminSection section = (AdminSection) expression.execute(arguments.getConfiguration(), arguments);
if (section != null) {
HttpServletRequest request = ((SpringWebContext) arguments.getContext()).getHttpServletRequest();
href = request.getContextPath() + section.getUrl();
}
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("href", href);
return attrs;
}
示例3: createHtmlContentFromTemplate
import org.thymeleaf.spring4.context.SpringWebContext; //导入依赖的package包/类
private String createHtmlContentFromTemplate(final User user, final Locale locale, final HttpServletRequest request,
final HttpServletResponse response) {
Map<String, Object> variables = new HashMap<>();
variables.put("user", user);
variables.put("baseUrl", request.getScheme() + "://" + // "http" + "://
request.getServerName() + // "myhost"
":" + request.getServerPort());
IWebContext context = new SpringWebContext(request, response, servletContext,
locale, variables, applicationContext);
return templateEngine.process("activationEmail", context);
}
示例4: createHtmlContentFromTemplate
import org.thymeleaf.spring4.context.SpringWebContext; //导入依赖的package包/类
private String createHtmlContentFromTemplate(final User user, final Locale locale, final HttpServletRequest request,
final HttpServletResponse response) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("user", user);
variables.put("baseUrl", request.getScheme() + "://" + // "http" + "://
request.getServerName() + // "myhost"
":" + request.getServerPort());
IWebContext context = new SpringWebContext(request, response, servletContext,
locale, variables, applicationContext);
return templateEngine.process(MailService.EMAIL_ACTIVATION_PREFIX + MailService.TEMPLATE_SUFFIX, context);
}
示例5: createHtmlContentFromTemplate
import org.thymeleaf.spring4.context.SpringWebContext; //导入依赖的package包/类
private String createHtmlContentFromTemplate(final User user, final Locale locale, final HttpServletRequest request,
final HttpServletResponse response) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("user", user);
variables.put("baseUrl", request.getScheme() + "://" + // "http" + "://
request.getServerName() + // "myhost"
":" + request.getServerPort());
IWebContext context = new SpringWebContext(request, response, servletContext,
locale, variables, applicationContext);
return templateEngine.process("activationEmail", context);
}
示例6: evaluateTemplate
import org.thymeleaf.spring4.context.SpringWebContext; //导入依赖的package包/类
public String evaluateTemplate(String templateName, Locale locale, Map<String,?> variables) {
IWebContext context = new SpringWebContext(request, null, servletContext, locale, variables, applicationContext);
return templateEngine.process(templateName, context);
}
示例7: getServletContext
import org.thymeleaf.spring4.context.SpringWebContext; //导入依赖的package包/类
private ServletContext getServletContext(Arguments arguments) {
SpringWebContext ctx = (SpringWebContext)arguments.getContext();
ServletContext application = ctx.getServletContext();
return application;
}