thymeleaf / thymeleaf-extras-springsecurity

Thymeleaf "extras" integration module for Spring Security 3.x and 4.x
http://www.thymeleaf.org
Apache License 2.0
477 stars 107 forks source link

Error with template thymeleaf and unknown code errors #80

Closed belsouza closed 3 years ago

belsouza commented 3 years ago

Hi! I'm following a tutorial to learn spring boot and when I implemented the spring boot security part (password encoder), the page with form (thymeleaf) stopped rendering. The worst thing is that every time I recompile the error code changes and I don't know what to do. I'm studying and before installing the security I was correctly rendering the thymeleaf template. The fact is that when I placed Spring Security, the Template stopped being rendered. Sorry, but I'm new to this. Another thing I don't understand is that every rendering has the same error description, but with different codes. I'm using spring's default configuration:

2021-08-21 14:51:56.839 ERROR 6316 --- [nio-8080-exec-4] seErrorMvcAutoConfiguration$StaticView : Cannot render error page for request [/users/new] and exception [An error happened during template parsing (template: "class path resource [templates/administration/new_user.html]")] as the response has already been committed. As a result, the response may have the wrong status code.

2021-08-21 15:11:59.584 ERROR 10672 --- [nio-8080-exec-6] seErrorMvcAutoConfiguration$StaticView : Cannot render error page for request [/users/new] and exception [An error happened during template parsing (template: "class path resource [templates/administration/new_user.html]")] as the response has already been committed. As a result, the response may have the wrong status code.

2021-08-21 15:19:30.500 ERROR 4776 --- [io-8080-exec-10] seErrorMvcAutoConfiguration$StaticView : Cannot render error page for request [/users/new] and exception [An error happened during template parsing (template: "class path resource [templates/administration/new_user.html]")] as the response has already been committed. As a result, the response may have the wrong status code.

2021-08-21 15:29:34.854 ERROR 9076 --- [nio-8080-exec-5] seErrorMvcAutoConfiguration$StaticView : Cannot render error page for request [/users/new] and exception [An error happened during template parsing (template: "class path resource [templates/administration/new_user.html]")] as the response has already been committed. As a result, the response may have the wrong status code.

ultraq commented 3 years ago

Hi there, do you have a link to the tutorial you followed? I wonder if I follow along then I might be able to get to the step that's been giving you problems and then replicate it.

belsouza commented 3 years ago

Thanks. This tutorial : https://www.youtube.com/watch?v=rFSxmKen6aQ&ab_channel=CodeJava I found the problem: Spring security crashed because of a thymeleaf template feature. Apparently thymeleaf renders the page even with "errors": in this case it was a div with a container opened in one fragment and closed in another (the same principle as wordpress templates). Even with the errors pointed out in the IDE, thymeleaf rendered the html correctly aligned, but when the security was enabled, the "errors" were blocked not allowing the rendering of the page (even if the final result was a valid html). It seems that if there is something in the template, the other elements of the pages that receive the template stop working.

The code is here: https://replit.com/@TheUnknownNoob/TenseUnequaledSystemcall