use of org.springframework.web.bind.annotation.InitBinder in project spring-hibernate by WeInnovate.
the class StudentController method anyMethod.
@InitBinder
public void anyMethod(WebDataBinder webDataBinder) {
StringTrimmerEditor ste = new StringTrimmerEditor(true);
webDataBinder.registerCustomEditor(String.class, ste);
}
use of org.springframework.web.bind.annotation.InitBinder in project Gemma by PavlidisLab.
the class BaseFormController method initBinder.
/**
* Set up a custom property editor for converting form inputs to real objects. Override this to add additional
* custom editors (call super.initBinder() in your implementation)
*/
@InitBinder
protected void initBinder(WebDataBinder binder) {
NumberFormat nf = NumberFormat.getNumberInstance();
binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, nf, true));
binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(Long.class, nf, true));
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
use of org.springframework.web.bind.annotation.InitBinder in project wechat by dllwh.
the class BaseController method initBinder.
/**
* ----------------------------------------------------- Fields end
*/
/**
* @方法:将前台传递过来的日期格式的字符串,自动转化为Date类型
* @创建人:独泪了无痕
* @param binder
*/
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
// String类型转换,将所有传递进来的String进行HTML编码,防止XSS攻击
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
}
@Override
public String getAsText() {
Object value = getValue();
return value != null ? value.toString() : "";
}
});
// Date 类型转换
binder.registerCustomEditor(Date.class, new DateConvertEditor());
}
use of org.springframework.web.bind.annotation.InitBinder in project spring-data-document-examples by spring-projects.
the class RestaurantController method registerConverters.
@InitBinder
void registerConverters(WebDataBinder binder) {
if (binder.getConversionService() instanceof GenericConversionService) {
GenericConversionService conversionService = (GenericConversionService) binder.getConversionService();
conversionService.addConverter(getRestaurantConverter());
}
}
use of org.springframework.web.bind.annotation.InitBinder in project spring-data-document-examples by spring-projects.
the class SignUpController method registerConverters.
@InitBinder
void registerConverters(WebDataBinder binder) {
if (binder.getConversionService() instanceof GenericConversionService) {
GenericConversionService conversionService = (GenericConversionService) binder.getConversionService();
conversionService.addConverter(getRestaurantConverter());
conversionService.addConverter(getUserAccountConverter());
conversionService.addConverter(getRestaurantConverterFromString());
}
}
Aggregations