I know struts2 default config will trim all strings obtained from forms.
For example:
I type
\" whatever \"in a form and submit, I will get
You can also use Spring's conversion service, which has the added benefit of working with and with Spring Webflow. As with the other answers, the major downside is that this is a global change and can't be disabled for certain forms.
You'll need a converter to do the trimming
public class StringTrimmingConverter implements Converter {
@Override
public String convert(String source) {
return source.trim();
}
}
Then define a conversion service that knows about your converter.
and tie that in to mvc.
If you use Spring Webflow then it require a wrapper
and a setting on your flow builder