Package org.thymeleaf.spring4.context
Class SpringContextUtils
- Object
-
- org.thymeleaf.spring4.context.SpringContextUtils
-
public class SpringContextUtils extends Object
Utility class for easy access of information stored at the context in a Spring-enabled application (such as the Spring ApplicationContext).
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.springframework.context.ApplicationContextgetApplicationContext(org.thymeleaf.context.ITemplateContext context)Get theApplicationContextfrom the Thymeleaf template context.
-
-
-
Method Detail
-
getApplicationContext
public static org.springframework.context.ApplicationContext getApplicationContext(org.thymeleaf.context.ITemplateContext context)
Get the
ApplicationContextfrom the Thymeleaf template context.Note that the application context might not be always accessible (and thus this method can return
null). Application Context will be accessible when the template is being executed as a Spring View, or else when an object of classThymeleafEvaluationContexthas been explicitly set into theITemplateContextcontextwith variable nameThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME.- Parameters:
context- the template context.- Returns:
- the application context, or
nullif it could not be accessed.
-
-