0
我正在学习scalate模板引擎。如何将我的控制器中的对象(例如用户)传递到我的Scalate模板中的模板.ssp?如何将sprint中的属性传递给scalate模板?
我控制器
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! the client locale is "+ locale.toString());
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate);
User user = new User("Dawid", "Pacholczyk");
model.addAttribute(user);
return "defaultTemplate";
}
感谢您效应初探。我编辑了我的帖子,并发布了我的控制器。正如你可以看到我回来的模板名,所以我不知道如何将这与你的方法:( – Fixus 2012-03-17 18:57:02
@Fixus更新的答案。 – ebaxt 2012-03-17 19:02:02
你是awsome。你解决了我的问题与模板。但我仍然得到例外:/ org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常为org.fusesource.scalate.CompilerException:编译失败: /WEB-INF/scalate/defaultTemplate.ssp:3.13错误:找不到:type User <%@ var user:User%> – Fixus 2012-03-17 19:07:35