本文整理匯總了Java中org.springframework.validation.BeanPropertyBindingResult.rejectValue方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanPropertyBindingResult.rejectValue方法的具體用法?Java BeanPropertyBindingResult.rejectValue怎麽用?Java BeanPropertyBindingResult.rejectValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.validation.BeanPropertyBindingResult
的用法示例。
在下文中一共展示了BeanPropertyBindingResult.rejectValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: withErrors
import org.springframework.validation.BeanPropertyBindingResult; //導入方法依賴的package包/類
@Test
public void withErrors() throws Exception {
this.tag.setPath("name");
this.tag.setCssClass("good");
this.tag.setCssErrorClass("bad");
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.rob, COMMAND_NAME);
errors.rejectValue("name", "some.code", "Default Message");
errors.rejectValue("name", "too.short", "Too Short");
exposeBindingResult(errors);
assertEquals(Tag.SKIP_BODY, this.tag.doStartTag());
String output = getOutput();
assertTagOpened(output);
assertTagClosed(output);
assertContainsAttribute(output, "type", getType());
assertValueAttribute(output, "Rob");
assertContainsAttribute(output, "class", "bad");
}
示例2: testWithErrors
import org.springframework.validation.BeanPropertyBindingResult; //導入方法依賴的package包/類
public void testWithErrors() throws Exception {
this.tag.setPath("name");
this.tag.setCssClass("good");
this.tag.setCssErrorClass("bad");
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.rob, COMMAND_NAME);
errors.rejectValue("name", "some.code", "Default Message");
errors.rejectValue("name", "too.short", "Too Short");
exposeBindingResult(errors);
assertEquals(Tag.SKIP_BODY, this.tag.doStartTag());
String output = getOutput();
assertTagOpened(output);
assertTagClosed(output);
assertContainsAttribute(output, "type", getType());
assertValueAttribute(output, "Rob");
assertContainsAttribute(output, "class", "bad");
}
示例3: handleMethodArgumentNotValid
import org.springframework.validation.BeanPropertyBindingResult; //導入方法依賴的package包/類
@Test
public void handleMethodArgumentNotValid() throws Exception {
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(new TestBean(), "testBean");
errors.rejectValue("name", "invalid");
MethodParameter parameter = new MethodParameter(this.getClass().getMethod("handle", String.class), 0);
MethodArgumentNotValidException ex = new MethodArgumentNotValidException(parameter, errors);
ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
assertNotNull("No ModelAndView returned", mav);
assertTrue("No Empty ModelAndView returned", mav.isEmpty());
assertEquals("Invalid status code", 400, response.getStatus());
}