我正在尝试编写freemarker模板,但无法使用我的对象类进行解析。
我的POJO
public class Metrix {
@Id
String _id;
String loginId;
Date date;
List<MatrixDetail> headers;
//All getters and setters
}
public class MatrixDetail {
String header;
int time;
String detail;
//All getters and setters
}
//保存表单后的控制器
@RequestMapping(value = "/matrix/save", method = RequestMethod.POST)
public View saveMatrix(@ModelAttribute Metrix matrix, ModelMap model) {
System.out.println("Reachecd in matrix save" );
return new RedirectView("/TrackerApplication/header.html");
}
FTL模板表格部分
<form name="matrix" action="matrix/save.html" method="post">
<table class="datatable" align:"center">
<tr>
<th>Login Id:</th> <th> <input type="text" name="loginId" value= ${matrixList.loginId} required /> </th>
</tr>
<tr> <td></td><td></td><td></td></tr>
<tr>
<th>Header</th> <th>Time</th> <th>Details</th>
</tr>
**// I am not getting how this nested object which is of type List<MatrixDetail>
// will get parse in my form.**
<#list matrixList.headers as header>
<spring:bind path = "MatrixDetail">
<tr>
<td> <input name = "header" value = ${header.header} /> </td>
<td> <input name = "time" value = ${header.time} /> </td>
<td> <input name = "detail" value = ${header.detail} /></td></tr>
</#list>
</table>
<input type="submit" value="Save" />
</form>
我们如何为这种嵌套对象的表单处理编写freemarker模板? 我在提交表单时遇到问题。
答案 0 :(得分:0)
我强烈建议不要这样做。
在某些情况下,表单可能会在电子邮件中显示,但they may not always work in the email client,更不用说那些只以纯文本形式阅读电子邮件的表单将无法使用它们。
如果您需要用户输入表单,请链接到您网站上的网页,并在那里填写表单。