- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个 spring boot 应用程序,我在其中使用英语和法语两种语言。我有我的文件 messages.fr 和 messages.en 作为引用,在 thymeleaf 的帮助下更改 html 文档中的语言。
我的重音内容看起来像这样的问题:例如“Cr�er un compte”(创建一个帐户)应该是:“Créer un compte”
在 spring boot 中完成此操作的最佳方法是什么?谢谢你的帮助..
请记住,我的属性中有这个 thymeleaf 配置
# INTERNATIONALIZATION (MessageSourceProperties)
spring.messages.always-use-message-format=false
spring.messages.basename=messages
spring.messages.cache-duration=-1
spring.messages.encoding=UTF-8
spring.messages.fallback-to-system-locale=true
#Thymeleaf configurations
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false
spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true
spring.thymeleaf.content-type=text/html
spring.thymeleaf.enabled=true
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.suffix=.html
spring.thymeleaf.prefix=classpath:/templates/
我在我的配置中使用了这些bean
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
LocaleChangeInterceptor.setParamName("lang");
return localeChangeInterceptor;
}
@Bean
public LocaleResolver localeResolver() {
final CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH);
return cookieLocaleResolver;
}
public void addInterceptors(InterceptorRegistry registry){
registry.addInterceptor(localeChangeInterceptor());
}
我运行这段代码来测试内容类型
@RequestMapping(value = "/check", method = RequestMethod.GET)
@ResponseBody
public String plaintext(HttpServletResponse response) {
response.setContentType("text/plain");
esponse.setCharacterEncoding("UTF-8");
return "àèääèäé";
}
它正确地返回相同的值:àèääèäé with accents
最佳答案
实际上,我过去也有过类似的经历,在 Spring Web 应用程序中,语言不会出现重音符号。
在我阅读了 github 上关于它的小讨论后,查看此链接
https://github.com/spring-projects/spring-boot/issues/5361
他们提到 java 在 ISO-8859-1 中具有基本编码,而 spring 在 UTF-8 中进行编码,这会导致一些不兼容。但是我不知道技术上为什么,但我记得更改我的属性并且它起作用了。
你可以尝试改变你的属性并替换
spring.messages.encoding=UTF-8
通过
spring.messages.encoding=ISO-8859-1
关于java - 国际化(语言环境)在 java spring boot 中不使用重音符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50225180/
我正在寻找一种方法来支持不区分大小写 + 重音不区分搜索的良好性能。到目前为止,我们在使用 MSSql 服务器时没有遇到任何问题,在 Oracle 上我们必须使用 OracleText,而现在我们在
这个问题已经有答案了: Trouble with UTF-8 characters; what I see is not what I stored (5 个回答) 已关闭 5 年前。 我刚刚将一个我
我正在寻找一种在 Linux 中使用反引号 (`)/波形符 (~) 键和其他一些键创建键盘快捷键的方法。在理想情况下: 按下波形符没有任何作用 按下波形符的同时按另一个键会触发(可自定义的)快捷方式
我有一个由术语组成的数组,其中一些包含重音字符。我像这样做一个 preg grep $data= array('Napoléon','Café'); $result = preg_grep('~' .
我使用 TextBox 在 DataGridView 中进行过滤 image .这是完美的工作。表格的单元格包含 1250 个拉丁字符。我想搜索忽略单元格中单词的重音。例子。如果是文本框 "knjaz
我在 Vim 中遇到一个奇怪的映射问题。我使用的是 Azerty 键盘。 在我的 .vimrc 中,我有以下命令可以在段落之间快速移动。 nnoremap _ { vnoremap _ { nnore
我尝试读取一个utf8编码的vcf文件,结果是: { "name": "=4A=61=76=69=65=72=20=4C=75=6A=C3=A1=6E", "tel":
我的数据库中有两个表,info 和 comment,它们的结构如下: info (id(int(10)), name(varchar(80)), ...19 other columns.., phon
我使用 QtWebkit 制作了一个应用程序。在同一个 html 页面中,在 Windows 上使用重音符号(西类牙语)时可以正常工作,但在 Linux (Ubuntu) 上则不起作用。 我不明白为什
我有(例如)两个字符串: $a = "joao"; $b = "joão"; if ( strtoupper($a) == strtoupper($b)) { echo $b; } 我希望它是
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: invalid multibyte char (US-ASCII) with Rails and Ruby
我重写 URL 以包含用户生成的旅游博客的标题。 我这样做是为了 URL 的可读性和 SEO 目的。 http://www.example.com/gallery/280-Gorges_du_Tod
我最近安装了新的 Windows 10 build 14393,我想使用新的 linux 子系统。所以我决定学习 ncurses,但我找不到如何从 getch 中获取带有重音符的字符的 UTF-8 代
我是一名优秀的程序员,十分优秀!