0
我想使用百里香叶模板引擎从属性文件中传递地图。如何通过百里香叶中的地图(春季4)
例外:
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'title' cannot be found on object of type 'java.lang.String' - maybe not public?
provider.html:
<!DOCTYPE>
<html th:include="receiver :: receiver(#{site})"></html>
receiver.html:
<!DOCTYPE HTML>
<html th:fragment="receiver(map)">
<head>
<title th:text="${map.title}">title</title>
</head>
<body th:text="${map.body}">
body
</body>
</html>
messages.properties:
site.title = Any title
site.body = Any body
控制器:
@Controller
public class StartController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String start(Model model) {
return "provider";
}
}
并没有为我工作了。 我现在得到这样的信息:属性或字段“标题”不能在空 找到我编辑接收器以这样的: :片段=“接收器(地图)”个:每= “条目:$ {地图}”>
<标题日:文本= “$ {entry.title}”>标题 <体日:文本= “$ {entry.body}”> 体