正如所建议我在新主题中提出新问题。
将参数传递给我的scalate模板(.ssp)
时遇到问题在我的控制器和模板下面
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView home(Locale locale, Model model) {
User user = new User("Dawid", "Pacholczyk");
ModelAndView template = new ModelAndView("defaultTemplate");
template.addObject("user", user);
return template;
}
<%@ val bar: String = "this is the default value" %>
<% attributes("title") = "This is the custom title" %>
<%@ var user: User %>
<p>Hi ${user.name},</p>
#do(layout("layouts/default.ssp"))
this is some template output...
<br />
${bar}
#end
现在我得到例外:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.fusesource.scalate.CompilerException: Compilation failed: /WEB-INF/scalate/defaultTemplate.ssp:3.13 error: not found: type User ^ org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
现在我不知道该怎么办。我要补充一点,当我删除<%@ var user: User %>
时,一切都很有效
怎么办?
答案 0 :(得分:2)
您需要先导入用户才能使用它。
<% import somePackage.User %>