Monday, June 4, 2012

Spring Custom Converter

Recently I ran into a problem where Spring would automatically convert comma separated String into String array, and quick search in google, I found people have the same problem on

Read more about Spring Converter

Just a summary of the solution.

1. Create Custom Converter for String to String[]

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

public class CustomStringToArrayConverter implements Converter{
    public String[] convert(String source) {
        return StringUtils.delimitedListToStringArray(source, ";");

2. Register the Custom Conveter.

specify this conversion service bean in your configuration:


1 comment: