0
私はscalateテンプレートエンジンを学習しています。コントローラからオブジェクト(例:User)をスケーラビリティテンプレートのテンプレート.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";
}
はREPONSEしていただきありがとうございます。私は私の投稿を編集し、私は自分のコントローラを投稿しました。あなたが見ることができるように私はテンプレート名を返すので、これをあなたのメソッドと組み合わせる方法は分かりません:( – Fixus
@Fixus updated answer。 – ebaxt
あなたは素晴らしいです。あなたは私の問題をテンプレートで解決しました。 :/ org.springframework.web.util.NestedServletException:リクエストの処理に失敗しました。ネストされた例外はorg.fuseource.scalate.CompilerExceptionです:コンパイルに失敗しました: /WEB-INF/scalate/defaultTemplate.ssp:3.13エラー:見つからない:type User <%@ var user:User%> – Fixus