skill/Java.Kotlin

[Java] springframework get method request param 배열일 경우, 콤마가 배열로 나눠서 오는 경우 error

have a nice day :D 2023. 10. 18. 15:51
반응형
import org.springframework.beans.propertyeditors.CustomCollectionEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController 
public class className {
    @InitBinder
    public void initBinder(WebDataBinder binder) {
      /* get method : request param list data ',' 처리 */
      binder.registerCustomEditor(List.class, new CustomCollectionEditor(List.class));
    }
}
반응형