本文整理汇总了Java中org.springframework.validation.MessageCodesResolver类的典型用法代码示例。如果您正苦于以下问题:Java MessageCodesResolver类的具体用法?Java MessageCodesResolver怎么用?Java MessageCodesResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageCodesResolver类属于org.springframework.validation包,在下文中一共展示了MessageCodesResolver类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testConstructFromSpringErrors
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
@Test
public void testConstructFromSpringErrors() {
MessageCodesResolver mockMessageCodesResolver = mock(MessageCodesResolver.class);
when(mockMessageCodesResolver.resolveMessageCodes("default.blank.message", "foo", "bar", null)).thenReturn(new String[] {"Property [bar] cannot be blank"});
when(mockMessageCodesResolver.resolveMessageCodes("default.blank.message", "foo", "baz", null)).thenReturn(new String[] {"Property [baz] cannot be blank"});
MapBindingResult errors = new MapBindingResult(new HashMap(), "foo");
errors.setMessageCodesResolver(mockMessageCodesResolver);
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "bar", "default.blank.message");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "baz", "default.blank.message");
JsonCError jsonc = new JsonCError(errors);
assertThat(jsonc.getCode(), is("Property [bar] cannot be blank"));
assertThat(jsonc.getMessage(), is("Field error in object 'foo' on field 'bar': rejected value [null]; codes [Property [bar] cannot be blank]; arguments []; default message [null]"));
List<Map<String,Object>> errorList = jsonc.getErrors();
assertThat((String) errorList.get(0).get("code"), is("Property [bar] cannot be blank"));
assertThat((String) errorList.get(0).get("message"), is("Field error in object 'foo' on field 'bar': rejected value [null]; codes [Property [bar] cannot be blank]; arguments []; default message [null]"));
assertThat((String) errorList.get(1).get("code"), is("Property [baz] cannot be blank"));
assertThat((String) errorList.get(1).get("message"), is("Field error in object 'foo' on field 'baz': rejected value [null]; codes [Property [baz] cannot be blank]; arguments []; default message [null]"));
}
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:23,代码来源:JsonCErrorTests.java
示例2: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
public MessageCodesResolver getMessageCodesResolver() {
List<MessageCodesResolver> candidates = new ArrayList<MessageCodesResolver>();
for (WebMvcConfigurer configurer : this.delegates) {
MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver();
if (messageCodesResolver != null) {
candidates.add(messageCodesResolver);
}
}
return selectSingleInstance(candidates, MessageCodesResolver.class);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:WebMvcConfigurerComposite.java
示例3: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
@Override
public MessageCodesResolver getMessageCodesResolver() {
List<MessageCodesResolver> candidates = new ArrayList<MessageCodesResolver>();
for (WebMvcConfigurer configurer : this.delegates) {
MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver();
if (messageCodesResolver != null) {
candidates.add(messageCodesResolver);
}
}
return selectSingleInstance(candidates, MessageCodesResolver.class);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:WebMvcConfigurerComposite.java
示例4: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
@SuppressWarnings("serial")
@Override
public MessageCodesResolver getMessageCodesResolver() {
return new DefaultMessageCodesResolver() {
@Override
public String[] resolveMessageCodes(String errorCode, String objectName) {
return new String[] { "custom." + errorCode };
}
};
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:WebMvcConfigurationSupportExtensionTests.java
示例5: testMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
@Test
public void testMessageCodesResolver() {
loadBeanDefinitions("mvc-config-message-codes-resolver.xml");
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter);
Object initializer = adapter.getWebBindingInitializer();
assertNotNull(initializer);
MessageCodesResolver resolver = ((ConfigurableWebBindingInitializer) initializer).getMessageCodesResolver();
assertNotNull(resolver);
assertEquals(TestMessageCodesResolver.class, resolver.getClass());
assertEquals(false, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:AnnotationDrivenBeanDefinitionParserTests.java
示例6: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
@Override
public MessageCodesResolver getMessageCodesResolver() {
if (this.mvcProperties.getMessageCodesResolverFormat() != null) {
DefaultMessageCodesResolver resolver = new DefaultMessageCodesResolver();
resolver.setMessageCodeFormatter(
this.mvcProperties.getMessageCodesResolverFormat());
return resolver;
}
return null;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:WebMvcAutoConfiguration.java
示例7: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* Return the strategy to use for resolving errors into message codes.
*/
public final MessageCodesResolver getMessageCodesResolver() {
return this.messageCodesResolver;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ConfigurableWebBindingInitializer.java
示例8: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
@Override
public MessageCodesResolver getMessageCodesResolver() {
return null;
}
开发者ID:Nbsaw,项目名称:miaohu,代码行数:5,代码来源:WebConfig.java
示例9: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* Override this method to provide a custom {@link MessageCodesResolver}.
*/
protected MessageCodesResolver getMessageCodesResolver() {
return null;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:WebMvcConfigurationSupport.java
示例10: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>This implementation is empty.
*/
@Override
public MessageCodesResolver getMessageCodesResolver() {
return null;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:WebMvcConfigurerAdapter.java
示例11: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
@Override
protected MessageCodesResolver getMessageCodesResolver() {
return this.configurers.getMessageCodesResolver();
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:DelegatingWebMvcConfiguration.java
示例12: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* Return the strategy to use for resolving errors into message codes (if any).
*/
public final MessageCodesResolver getMessageCodesResolver() {
return this.messageCodesResolver;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:7,代码来源:BaseCommandController.java
示例13: setMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* Set the strategy to use for resolving errors into message codes.
* Applies the given strategy to all data binders used by this controller.
* <p>Default is {@code null}, i.e. using the default strategy of
* the data binder.
* @see org.springframework.validation.DataBinder#setMessageCodesResolver
*/
public final void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) {
this.messageCodesResolver = messageCodesResolver;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ConfigurableWebBindingInitializer.java
示例14: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* Provide a custom {@link MessageCodesResolver} for building message codes
* from data binding and validation error codes. Leave the return value as
* {@code null} to keep the default.
*/
MessageCodesResolver getMessageCodesResolver();
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:WebMvcConfigurer.java
示例15: setMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* Set the strategy to use for resolving errors into message codes.
* Applies the given strategy to all data binders used by this controller.
* <p>Default is {@code null}, i.e. using the default strategy of
* the data binder.
* @see #createBinder
* @see org.springframework.validation.DataBinder#setMessageCodesResolver
*/
public final void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) {
this.messageCodesResolver = messageCodesResolver;
}
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:12,代码来源:BaseCommandController.java
示例16: setMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* Set the strategy to use for resolving errors into message codes.
* Applies the given strategy to all data binders used by this controller.
* <p>Default is {@code null}, i.e. using the default strategy of the data binder.
* @see #createBinder
* @see org.springframework.validation.DataBinder#setMessageCodesResolver
*/
public final void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) {
this.messageCodesResolver = messageCodesResolver;
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:BaseCommandController.java
示例17: getMessageCodesResolver
import org.springframework.validation.MessageCodesResolver; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>This implementation is empty.
*/
public MessageCodesResolver getMessageCodesResolver() {
return null;
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:WebMvcConfigurerAdapter.java
注:本文中的org.springframework.validation.MessageCodesResolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论