當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanPropertyBindingResult.rejectValue方法代碼示例

本文整理匯總了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");
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:22,代碼來源:InputTagTests.java

示例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");
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:21,代碼來源:InputTagTests.java

示例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());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:12,代碼來源:DefaultHandlerExceptionResolverTests.java


注:本文中的org.springframework.validation.BeanPropertyBindingResult.rejectValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。