java - 诡异的 ?? en_US??出现在选项标签中

标签 java html spring thymeleaf

目前我在 Spring MVC 中有这段代码来填充所有选项,例如“Doctor”等...

@ModelAttribute("allTypes")
public List<String> populateType() {
String a[]= new String[]{"Doctor","Patient"}; 
return Arrays.asList(a);
}

这段 HTML 代码使用上面的代码来显示下拉列表中的选项。

<select th:field="*{type}">
<option value="NONE">------Select-------</option>
<option th:each="type:${allTypes}" th:value="${type}" th:text="#{${type}}"></option>
</select>

我遇到的问题是下拉列表中有奇怪的输出。例如 ??Doctor_en_US??,??Patient_en_US??。

感谢任何帮助。谢谢。

最佳答案

使用 Thymeleaf 消息表达式 (#{...}) 时会出现 ??Something_en_US?? 字符串,并且消息解析器无法解析该表达式中找到的消息代码。例如,#{foo} 需要在消息属性文件中包含一行,如下所示:

foo = Some message or text to display here

消息解析取决于 Thymeleaf 是否配置了 Spring 方言。引用文献:

关于java - 诡异的 ?? en_US??出现在选项标签中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26072397/

相关文章:

javascript - Css 垂直对齐浏览器高度

html - 在 WordPress 标题中垂直居中元素

Spring Boot 应用程序在 Brixton SR3 中向 Eureka 注册未知

java - 如何修复 Findbugs 问题 "Null value is guaranteed to be dereferenced"NP_GUARANTEED_DEREF

java - Maven : No tests were executed

java - jsp中的正则表达式

java - Hibernate boolean true_false 在 MySql 中产生一个字符......有时?

java - 什么是 "natural ordering"?

css - 单击元素时仅关注 contenteditable?

java - Spring 数据 REST : "no String-argument constructor/factory method to deserialize from String value"