데이터 바인딩 초기화에는 두 가지 주요 방법이 있지만 올드 스쿨의 단점이 있습니다. 알아낼 수없는 단점이 있습니다. 이 특수 효과 방법은 훌륭합니다.WebBindingInitializer에 @InitBinder 초기화 외부화
@InitBinder("order")
public void initBinder(WebDataBinder binder) {
// Problem is that I want to set allowed and restricted fields - can be done here
binder.setAllowedFields(allowedFields.split(","));
}
하지만 ConfigurableWebBindingInitializer로 수행 할 수 없습니다. 나는 이런 식으로 뭔가를 할 수 없어 ... 첫째, 바인더 인스턴스는 AnnotationMethodHandlerAdapter에 생성되고 초기화는 그래서 그것을 설정할 수 없습니다 HandlerMethodInvoker 어딘가에 바인더 인스턴스를 전달됩니다
<bean id="codesResolver" class="org.springframework.validation.DefaultMessageCodesResolver" />
<bean id="binder" class="org.springframework.web.portlet.bind.PortletRequestDataBinder" scope="prototype">
<property name="allowedFields" value="${allowedFields}" />
<aop:scoped-proxy />
</bean>
<bean id="webBindingInitializer" class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="messageCodesResolver" ref="codesResolver" />
</bean>
때문에 바인더 예 handlerAdapter에서 전달됩니다. 그럼 어떻게 바인더를 설정할 수 있습니까?