[英]Thymeleaf: placeHolders in property files
我有一個 SpringBoot 應用程序。 使用 Thymeleaf,使用此屬性文件:
signup.form.error.file.too.big=File ${fileName} is too Big
在控制器上:
if (Objects.nonNull(fileExceedsTheconfiguredMaximum)) {
hasErrors = true;
model.addAttribute("fileName", fileExceedsTheconfiguredMaximum.getOriginalFilename());
}
在模板上:
<li th:if="${fileToBig}" th:text="#{signup.form.error.file.too.big}" />
但我在瀏覽器上看到了這個:
File ${fileName} is too Big
以#{fileName}
的文件名無濟於事。 您可以使用${fileName}
添加文件名。
<li th:if="${fileToBig}" th:text="#{signup.form.error.file.too.big(${fileName})}" />
您需要對代碼進行一些更改。
按以下方式更改消息屬性:
signup.form.error.file.too.big=File {0} is too Big
另一個變化是在 thymeleaf 模板文件中:
<li th:if="${fileToBig}" th:text="#{signup.form.error.file.too.big(${fileName})}" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.