hibernate-mile米乐体育

目录

* comma-separated list of basenames, each following the resourcebundle convention. * essentially a fully-qualified classpath location. if it doesn't contain a package * qualifier (such as "org.mypackage"), it will be resolved from the classpath root. */ private string basename = "messages"; /** * message bundles encoding. */ private charset encoding = charset.forname("utf-8"); /** * loaded resource bundle files cache expiration, in seconds. when set to -1, bundles * are cached forever. */ private int cacheseconds = -1; /** * set whether to fall back to the system locale if no files for a specific locale * have been found. if this is turned off, the only fallback will be the default file * (e.g. "messages.properties" for basename "messages"). */ private boolean fallbacktosystemlocale = true; /** * set whether to always apply the messageformat rules, parsing even messages without * arguments. */ private boolean alwaysusemessageformat = false; @bean public messagesource messagesource() { resourcebundlemessagesource messagesource = new resourcebundlemessagesource(); if (stringutils.hastext(this.basename)) { messagesource.setbasenames(stringutils.commadelimitedlisttostringarray( stringutils.trimallwhitespace(this.basename))); } if (this.encoding != null) { messagesource.setdefaultencoding(this.encoding.name()); } messagesource.setfallbacktosystemlocale(this.fallbacktosystemlocale); messagesource.setcacheseconds(this.cacheseconds); messagesource.setalwaysusemessageformat(this.alwaysusemessageformat); return messagesource; } public string getbasename() { return this.basename; } public void setbasename(string basename) { this.basename = basename; } public charset getencoding() { return this.encoding; } public void setencoding(charset encoding) { this.encoding = encoding; } public int getcacheseconds() { return this.cacheseconds; } public void setcacheseconds(int cacheseconds) { this.cacheseconds = cacheseconds; } public boolean isfallbacktosystemlocale() { return this.fallbacktosystemlocale; } public void setfallbacktosystemlocale(boolean fallbacktosystemlocale) { this.fallbacktosystemlocale = fallbacktosystemlocale; } public boolean isalwaysusemessageformat() { return this.alwaysusemessageformat; } public void setalwaysusemessageformat(boolean alwaysusemessageformat) { this.alwaysusemessageformat = alwaysusemessageformat; } protected static class resourcebundlecondition extends springbootcondition { private static concurrentreferencehashmap cache = new concurrentreferencehashmap(); @override public conditionoutcome getmatchoutcome(conditioncontext context, annotatedtypemetadata metadata) { string basename = context.getenvironment() .getproperty("spring.messages.basename", "messages"); conditionoutcome outcome = cache.get(basename); if (outcome == null) { outcome = getmatchoutcomeforbasename(context, basename); cache.put(basename, outcome); } return outcome; } private conditionoutcome getmatchoutcomeforbasename(conditioncontext context, string basename) { conditionmessage.builder message = conditionmessage .forcondition("resourcebundle"); for (string name : stringutils.commadelimitedlisttostringarray( stringutils.trimallwhitespace(basename))) { for (resource resource : getresources(context.getclassloader(), name)) { if (resource.exists()) { return conditionoutcome .match(message.found("bundle").items(resource)); } } } return conditionoutcome.nomatch( message.didnotfind("bundle with basename " basename).atall()); } private resource[] getresources(classloader classloader, string name) { try { return new pathmatchingresourcepatternresolver(classloader) .getresources("classpath*:" name ".properties"); } catch (exception ex) { return no_resources; } } } }

  从上面的messagesource自动配置可以看出,可以通过spring.message.basename指定要配置国际化文件位置,默认值是“message”。spring boot默认就支持国际化的,默认会去resouces目录下寻找message.properties文件。

  这里就不进行过多关于国际化相关信息的介绍了,肯定少不了区域解析www.cppcns.com器。springboot国际化相关知识请参考:spring boot国际化(i18n)

到此这篇关于hibernate-validator如何使用校验框架的文章就介绍到这了,更多相关hibernate-validator校验内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

展开全文
内容来源于互联网和用户投稿,文章中一旦含有米乐app官网登录的联系方式务必识别真假,本站仅做信息展示不承担任何相关责任,如有侵权或涉及法律问题请联系米乐app官网登录删除

最新文章

网站地图