====== SpringMVC @InitBinder ====== ===== 파라미터의 a=1,2,3 을 문자열로 그대로 "1,2,3"으로 받기 ===== * 기본적으로 문자열 파라미터가 쉼표로 들어오면 배열이나 List로 넘김 * [[http://stackoverflow.com/questions/4998748/how-to-prevent-parameter-binding-from-interpreting-commas-in-spring-3-0-5|java - How to prevent parameter binding from interpreting commas in Spring 3.0.5?]] @InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(String[].class, new StringArrayPropertyEditor(null)); } ===== String empty to null ===== * [[http://stackoverflow.com/questions/2977649/is-there-an-easy-way-to-turn-empty-java-spring-form-input-into-null-strings|Is there an easy way to turn empty Java/Spring form input into null strings?]] * [[http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/propertyeditors/StringTrimmerEditor.html|StringTrimmerEditor (Spring Framework 4.2.0.RELEASE API)]] 를 사용한다. @InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(String.class, new StringTrimmerEditor(true)); }