0

I have a SpringBoot app. with Thymeleaf, with this property file:

signup.form.error.file.too.big=File ${fileName} is too Big 

on the contoller:

if (Objects.nonNull(fileExceedsTheconfiguredMaximum)) {
            hasErrors = true;
            model.addAttribute("fileName", fileExceedsTheconfiguredMaximum.getOriginalFilename());
        }

on the template:

 <li th:if="${fileToBig}"  th:text="#{signup.form.error.file.too.big}" />

but I see this on the browser:

File ${fileName} is too Big
en Lopes
  • 1,863
  • 11
  • 48
  • 90

2 Answers2

1

Starting the filename with a #{fileName} won't help. You can add the file name with the ${fileName}.

<li th:if="${fileToBig}" th:text="#{signup.form.error.file.too.big(${fileName})}" />

Alternative answer.

İsmail Y.
  • 3,579
  • 5
  • 21
  • 29
0

You need to make a couple of changes to your code.

Change message property as per below:

signup.form.error.file.too.big=File {0} is too Big 

And the other change would be in a thymeleaf template file:

 <li th:if="${fileToBig}"  th:text="#{signup.form.error.file.too.big(${fileName})}" /> 
Govinda Sakhare
  • 5,009
  • 6
  • 33
  • 74