Spring 使用注释绑定数据
是否可以执行与此相同的行为:Spring 使用注释绑定数据,spring,spring-mvc,Spring,Spring Mvc,是否可以执行与此相同的行为: protected void onBind(HttpServletRequest request, Object command, BindException bindException) throws Exception { Invoice invoice = (Invoice) command; invoice.getLineItems().removeAll(Collections.singletonList(null)); } 当使用注释
protected void onBind(HttpServletRequest request, Object command, BindException bindException) throws Exception {
Invoice invoice = (Invoice) command;
invoice.getLineItems().removeAll(Collections.singletonList(null));
}
当使用注释时?
我使用@controller注释,因此没有onBind函数。我想计算一个元素列表(从列表中删除项) 新方法是使用注释对方法进行注释:
@InitBinder
protected void initBinder(WebDataBinder binder) {
...
}
您还可以注册属性编辑器,以便通过调用方法转换值。此外,对于转换为集合,还有一些可能很方便的方法