本文整理汇总了Java中org.springframework.context.support.ResourceBundleMessageSource.setDefaultEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundleMessageSource.setDefaultEncoding方法的具体用法?Java ResourceBundleMessageSource.setDefaultEncoding怎么用?Java ResourceBundleMessageSource.setDefaultEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.context.support.ResourceBundleMessageSource
的用法示例。
在下文中一共展示了ResourceBundleMessageSource.setDefaultEncoding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultMessageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public MessageSource defaultMessageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("messages", "i18n/messages");
messageSource.setDefaultEncoding(Charset.forName("UTF-8").name());
messageSource.setFallbackToSystemLocale(true);
messageSource.setCacheSeconds(-1);
messageSource.setAlwaysUseMessageFormat(false);
messageSource.setUseCodeAsDefaultMessage(true);
return messageSource;
}
示例2: onContextRefreshed
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Override
public void onContextRefreshed() {
Set<String> messages = new HashSet<>();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
for (String beanName : BeanFactory.getBeanNames()) {
Package beanPackage = BeanFactory.getBeanClass(beanName).getPackage();
if (beanPackage == null) {
logger.warn(null, "无法获得Bean[{}]包。", beanName);
continue;
}
String packageName = beanPackage.getName();
if (resolver.getResource(packageName.replace('.', File.separatorChar) + "/message.properties").exists())
messages.add(packageName);
}
String[] names = new String[messages.size()];
int i = 0;
for (String name : messages)
names[i++] = name + ".message";
messageSource = new ResourceBundleMessageSource();
messageSource.setDefaultEncoding(context.getCharset(null));
messageSource.setBasenames(names);
}
示例3: messageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public ResourceBundleMessageSource messageSource()
{
ResourceBundleMessageSource source = new ResourceBundleMessageSource();
source.setBasename("locale/messages");
source.setDefaultEncoding("UTF-8");
return source;
}
示例4: messageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource source = new ResourceBundleMessageSource();
source.setBasenames("i18n/messages");
source.setUseCodeAsDefaultMessage(true);
source.setDefaultEncoding("UTF-8");
return source;
}
示例5: messageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public MessageSource messageSource()
{
ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
resourceBundleMessageSource.setDefaultEncoding("UTF-8");
resourceBundleMessageSource.addBasenames("templates/index");
return resourceBundleMessageSource;
}
示例6: getMessageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
ResourceBundleMessageSource resource = new ResourceBundleMessageSource();
resource.setBasename("messages");
resource.setDefaultEncoding("UTF-8");
return resource;
}
示例7: createMessageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
/**
* Create a MessageSource for the given basename,
* to be used as MessageSource for the corresponding theme.
* <p>Default implementation creates a ResourceBundleMessageSource.
* for the given basename. A subclass could create a specifically
* configured ReloadableResourceBundleMessageSource, for example.
* @param basename the basename to create a MessageSource for
* @return the MessageSource
* @see org.springframework.context.support.ResourceBundleMessageSource
* @see org.springframework.context.support.ReloadableResourceBundleMessageSource
*/
protected MessageSource createMessageSource(String basename) {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(basename);
if (this.defaultEncoding != null) {
messageSource.setDefaultEncoding(this.defaultEncoding);
}
if (this.fallbackToSystemLocale != null) {
messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
}
if (this.beanClassLoader != null) {
messageSource.setBeanClassLoader(this.beanClassLoader);
}
return messageSource;
}
示例8: before
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Before
public void before() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("messages");
messageSource.setDefaultEncoding("UTF8");
clientEnumController = new ClientEnumController(messageSource);
clientEnumController.registerClientEnum(Gender.class);
}
示例9: validationMessageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public MessageSource validationMessageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("validation");
messageSource.setDefaultEncoding("utf8");
return messageSource;
}
示例10: createValidator
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
public static Validator createValidator() {
LocaleContextHolder.setLocale(Locale.ENGLISH);
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setFallbackToSystemLocale(false);
messageSource.setBasenames("validation");
messageSource.setDefaultEncoding("utf8");
LocalValidatorFactoryBean localValidator = new LocalValidatorFactoryBean();
localValidator.setValidationMessageSource(messageSource);
localValidator.afterPropertiesSet();
return localValidator;
}
示例11: messageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource resource = new ResourceBundleMessageSource();
resource.setBasename("messages");
resource.setDefaultEncoding(StandardCharsets.UTF_8.toString());
return resource;
}
示例12: mailSetup
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Before
public void mailSetup() {
configuration = new Configuration(Configuration.VERSION_2_3_21);
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateLoader(new ClassTemplateLoader(MailComposer.class, "/mail"));
//keep config same as application.yml and WebConfiguration.java
messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("i18n/messages");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setFallbackToSystemLocale(false);
}
示例13: messageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
resourceBundleMessageSource.setBasenames("GerenciarUsuarios");
resourceBundleMessageSource.setDefaultEncoding("UTF-8");
return resourceBundleMessageSource;
}
示例14: buildSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
private ResourceBundleMessageSource buildSource(String basename, ClassLoader classLoader) {
ResourceBundleMessageSource source = new ResourceBundleMessageSource();
source.setDefaultEncoding(StandardCharsets.UTF_8.name());
source.setFallbackToSystemLocale(false);
source.setBasename(basename);
if (classLoader == null) {
classLoader = LocalizationServiceImpl.class.getClassLoader();
}
source.setBundleClassLoader(classLoader);
return source;
}
示例15: messageSource
import org.springframework.context.support.ResourceBundleMessageSource; //导入方法依赖的package包/类
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
ms.setDefaultEncoding("UTF-8");
ms.setFallbackToSystemLocale(false);
ms.setBasename("i18n/messages");
return ms;
}