Closed parivero closed 9 years ago
I am trying to use a function and I'm not making it work.
This is the code I'm implementing:
Config
@Bean public ViewResolver getViewResolver(ResourceLoader resourceLoader) { MustacheViewResolver mustacheViewResolver = new MustacheViewResolver(); mustacheViewResolver.setPrefix("/WEB-INF/views/"); mustacheViewResolver.setSuffix(".html"); mustacheViewResolver.setCache(false); mustacheViewResolver.setContentType("text/html;charset=utf-8"); MustacheJTemplateFactory factory = new MustacheJTemplateFactory(); factory.setResourceLoader(resourceLoader); mustacheViewResolver.setTemplateFactory(factory); return mustacheViewResolver; }
template
{{#upper}}{{name}}{{/upper}}
controller
model.addAttribute("name","pablo"); model.addAttribute("upper",new Object() { Callable<Function> upper = new Callable<Function>() { @Override public Function call() throws Exception { return new Function() { @Override public Object apply(Object o) { return o.toString().toUpperCase(); } }; } }; });
and the result is pablo instead of PABLO.
Thanks in advance.
I am trying to use a function and I'm not making it work.
This is the code I'm implementing:
Config
template
controller
and the result is pablo instead of PABLO.
Thanks in advance.