本文整理匯總了Java中org.springframework.web.bind.annotation.InitBinder類的典型用法代碼示例。如果您正苦於以下問題:Java InitBinder類的具體用法?Java InitBinder怎麽用?Java InitBinder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
InitBinder類屬於org.springframework.web.bind.annotation包,在下文中一共展示了InitBinder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder("employeeForm")
public void initBinder(WebDataBinder binder){
binder.setValidator(employeeValidator);
binder.registerCustomEditor(Date.class, new DateEditor());
binder.registerCustomEditor(Integer.class, "age", new AgeEditor());
}
示例2: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(
Long.class,
new CustomNumberEditor(Long.class, true));
binder.registerCustomEditor(
Double.class,
new CustomNumberEditor(Double.class, true));
binder.registerCustomEditor(
BigDecimal.class,
new CustomNumberEditor(
BigDecimal.class,
new DecimalFormat("#,##0.00"),
true));
binder.registerCustomEditor(
Boolean.class,
new CustomBooleanEditor(true));
binder.registerCustomEditor(
Date.class,
new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
binder.registerCustomEditor(
Object.class,
new ObjectTypeEditorHelper());
}
示例3: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(SignatureForm.class, new EnumPropertyEditor(SignatureForm.class));
binder.registerCustomEditor(ASiCContainerType.class, new EnumPropertyEditor(ASiCContainerType.class));
binder.registerCustomEditor(SignaturePackaging.class, new EnumPropertyEditor(SignaturePackaging.class));
binder.registerCustomEditor(SignatureLevel.class, new EnumPropertyEditor(SignatureLevel.class));
binder.registerCustomEditor(DigestAlgorithm.class, new EnumPropertyEditor(DigestAlgorithm.class));
binder.registerCustomEditor(EncryptionAlgorithm.class, new EnumPropertyEditor(EncryptionAlgorithm.class));
}
示例4: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setAutoGrowNestedPaths(false);
binder.registerCustomEditor(
Long.class,
new CustomNumberEditor(Long.class, true));
binder.registerCustomEditor(
Double.class,
new CustomNumberEditor(Double.class, true));
binder.registerCustomEditor(
BigDecimal.class,
new CustomNumberEditor(
BigDecimal.class,
new DecimalFormat("#,##0.00"),
true));
binder.registerCustomEditor(
Boolean.class,
new CustomBooleanEditor(true));
binder.registerCustomEditor(
Date.class,
new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
binder.registerCustomEditor(
Object.class,
new ObjectTypeEditorHelper());
}
示例5: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(
byte[].class,
new ByteArrayMultipartFileEditor());
binder.registerCustomEditor(
Date.class,
new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
binder.registerCustomEditor(
Long.class,
new CustomNumberEditor(Long.class, true));
binder.registerCustomEditor(
Double.class,
new CustomNumberEditor(Double.class, true));
binder.registerCustomEditor(
BigDecimal.class,
new CustomNumberEditor(
BigDecimal.class,
new DecimalFormat("#,##0.00"),
true));
binder.registerCustomEditor(
Boolean.class,
new CustomBooleanEditor(false));
}
示例6: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(
Long.class,
new CustomNumberEditor(Long.class, true));
binder.registerCustomEditor(
Double.class,
new CustomNumberEditor(Double.class, true));
binder.registerCustomEditor(
BigDecimal.class,
new CustomNumberEditor(
BigDecimal.class,
new DecimalFormat("#,##0.00"),
true));
binder.registerCustomEditor(
Boolean.class,
new CustomBooleanEditor(false));
binder.registerCustomEditor(
Date.class,
new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
示例7: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(SignatureForm.class, new EnumPropertyEditor(SignatureForm.class));
binder.registerCustomEditor(ASiCContainerType.class, new EnumPropertyEditor(ASiCContainerType.class));
binder.registerCustomEditor(SignatureLevel.class, new EnumPropertyEditor(SignatureLevel.class));
binder.registerCustomEditor(DigestAlgorithm.class, new EnumPropertyEditor(DigestAlgorithm.class));
binder.registerCustomEditor(EncryptionAlgorithm.class, new EnumPropertyEditor(EncryptionAlgorithm.class));
}
示例8: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(ASiCContainerType.class, new EnumPropertyEditor(ASiCContainerType.class));
binder.registerCustomEditor(SignatureForm.class, new EnumPropertyEditor(SignatureForm.class));
binder.registerCustomEditor(SignaturePackaging.class, new EnumPropertyEditor(SignaturePackaging.class));
binder.registerCustomEditor(SignatureLevel.class, new EnumPropertyEditor(SignatureLevel.class));
}
示例9: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
binder.registerCustomEditor(Category.class, "categorySet", new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
Category category = categoryService.findByPK(Long.parseLong(text));
setValue(category);
}
});
}
示例10: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
binder.registerCustomEditor(Role.class, "roles", new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
Role role = roleService.findByPK(Long.parseLong(text));
setValue(role);
}
});
}
示例11: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
protected void initBinder(Object handler, String attrName, WebDataBinder binder, NativeWebRequest webRequest)
throws Exception {
if (this.bindingInitializer != null) {
this.bindingInitializer.initBinder(binder, webRequest);
}
if (handler != null) {
Set<Method> initBinderMethods = this.methodResolver.getInitBinderMethods();
if (!initBinderMethods.isEmpty()) {
boolean debug = logger.isDebugEnabled();
for (Method initBinderMethod : initBinderMethods) {
Method methodToInvoke = BridgeMethodResolver.findBridgedMethod(initBinderMethod);
String[] targetNames = AnnotationUtils.findAnnotation(initBinderMethod, InitBinder.class).value();
if (targetNames.length == 0 || Arrays.asList(targetNames).contains(attrName)) {
Object[] initBinderArgs =
resolveInitBinderArguments(handler, methodToInvoke, binder, webRequest);
if (debug) {
logger.debug("Invoking init-binder method: " + methodToInvoke);
}
ReflectionUtils.makeAccessible(methodToInvoke);
Object returnValue = methodToInvoke.invoke(handler, initBinderArgs);
if (returnValue != null) {
throw new IllegalStateException(
"InitBinder methods must not have a return value: " + methodToInvoke);
}
}
}
}
}
}
示例12: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
binder.registerCustomEditor(Role.class, "roles", new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
Role role = roleService.findByPK(Long.parseLong(text));
setValue(role);
}
});
}
示例13: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
/**
* 自動轉換日期類型的字段格式
*/
binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true));
/**
* 防止XSS攻擊
*/
binder.registerCustomEditor(String.class, new StringEscapeEditor());
}
示例14: initBinder
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat(
TodoListUtils.DATE_FORMAT);
binder.registerCustomEditor(Date.class, new CustomDateEditor(
dateFormat, false));
binder.registerCustomEditor(Priority.class,
new TodoPriorityPropertyEditor());
}
示例15: setAllowedFields
import org.springframework.web.bind.annotation.InitBinder; //導入依賴的package包/類
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}