【发布时间】:2014-07-24 16:38:31
【问题描述】:
我正在使用自定义 Thymeleaf 属性处理器将动态内容包含到视图中,该处理器在处理属性本身的同时简单地添加其他节点。
我使用的代码与下面的非常相似:
final Template template = arguments.getTemplateRepository().getTemplate(
new TemplateProcessingParameters(arguments.getConfiguration(), "name-of-a-view", arguments.getContext()));
final List<Node> children = template.getDocument().getChildren();
// Add to the tree.
for (final Node node : children) {
element.addChild(node);
}
这很好用,但是当包含的节点包含使用 th:object 和 th:field 的表单时会中断。
我将我需要的模型放在节点变量映射中,实际上 th:object 确实找到并检索了对象,但 th:field 似乎并不关心并以 a 中断
Neither BindingResult nor plain target object for bean name 'model' available as request attribute
根据我的理解(逐步调试),在我看来 th:field 只在请求上下文中搜索模型。
我错过了什么吗?
提前谢谢你。
【问题讨论】:
标签: thymeleaf