Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 使用注释绑定数据_Spring_Spring Mvc - Fatal编程技术网

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) {
        ...
}
您还可以注册
属性编辑器
,以便通过调用方法转换值。此外,对于转换为集合,还有一些可能很方便的方法