WebDataBinder

static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");

	@InitBinder
	protected void initBinder(WebDataBinder binder) throws Exception {
		// bind empty strings as null
		binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
		binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
		binder.registerCustomEditor(Integer.TYPE, new CustomNumberEditor(Integer.class, true) {

			public void setValue(Object o) {
				super.setValue((o == null) ? 0 : o);
			}
		});
	}



你可能感兴趣的:(WebDataBinder)