奇怪的 ?? EN_US?出现在选项标签中

时间:2014-09-27 07:30:39

标签: 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 ??。

感谢任何帮助。谢谢。

1 个答案:

答案 0 :(得分:0)

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

foo = Some message or text to display here

根据Thymeleaf是否配置了Spring方言,消息解析会有所不同。参考文献:

相关问题