thymeleaf

Upload files to the @ModelAttribute using Thymeleaf

删除回忆录丶 提交于 2021-02-07 10:50:29
问题 How to upload files to the @ModelAttribute using Thymeleaf? I'am doing something that: upload.html <form method="POST" action="#" th:action="@{/sending}" th:object="${collage}" enctype="multipart/form-data" > <input type="file" th:field="*{picture}" /> <input type="file" th:field="*{picture}" /> <input type="submit" value="upload" /> </form> My controller: @Controller public class MainController { @GetMapping(value = { "/" }) public String index(){ return "upload"; } @GetMapping("/collage")

Gif image not working in thymeleaf-html page?

杀马特。学长 韩版系。学妹 提交于 2021-02-07 09:14:29
问题 in html image and gif are set as same way. so i use same way in thymeleaf In thymeleaf the image set as <img th:attr="src=@{${ball.png}} , title=#{background}, alt=#{background}" style="width: 150px; height: 150px;" /> same as the gif image set as <img th:attr="src=@{${run.gif}} , title=#{background}, alt=#{background}" style="width: 150px; height: 150px;" /> the image will show there but gif image not shows there i don't know why this happening. if you know the answer please share here. 回答1:

Gif image not working in thymeleaf-html page?

匆匆过客 提交于 2021-02-07 09:12:03
问题 in html image and gif are set as same way. so i use same way in thymeleaf In thymeleaf the image set as <img th:attr="src=@{${ball.png}} , title=#{background}, alt=#{background}" style="width: 150px; height: 150px;" /> same as the gif image set as <img th:attr="src=@{${run.gif}} , title=#{background}, alt=#{background}" style="width: 150px; height: 150px;" /> the image will show there but gif image not shows there i don't know why this happening. if you know the answer please share here. 回答1:

How to use Thymeleaf th:text in reactJS

折月煮酒 提交于 2021-02-06 10:01:45
问题 I am running a springboot application with Thymeleaf and reactJS. All the HTML text are read from message.properties by using th:text in the pages, but when I have th:text in reactJS HTML block, reactJS seems angry about it. render() { return ( <input type="text" th:text="#{home.welcome}"> ) } The error is: Namespace tags are not supported. ReactJSX is not XML. Is there a walkaround besides using dangerouslySetInnerHTML? Thank you! 回答1: There is no sane workaround. You are getting this error

If-Else in a th:each statement in Thymeleaf

你说的曾经没有我的故事 提交于 2021-02-05 20:37:55
问题 What I want is an if-else in a th:each statement in Thymeleaf. If currentSkill != null , then show table with content, else 'You don't have any skills' This is the code without the if/else: <div th:each="skill : ${currentSkills}"> <table> <tr><td th:text="${skill.name}"/></tr> </table> </div> 回答1: <div th:if="${currentSkills != null}"> <table> <tr th:each="skill : ${currentSkills}"><td th:text="${skill.name}"/></tr> </table> </div> <div th:if="${currentSkills == null}"> You don't have any

If-Else in a th:each statement in Thymeleaf

…衆ロ難τιáo~ 提交于 2021-02-05 20:37:01
问题 What I want is an if-else in a th:each statement in Thymeleaf. If currentSkill != null , then show table with content, else 'You don't have any skills' This is the code without the if/else: <div th:each="skill : ${currentSkills}"> <table> <tr><td th:text="${skill.name}"/></tr> </table> </div> 回答1: <div th:if="${currentSkills != null}"> <table> <tr th:each="skill : ${currentSkills}"><td th:text="${skill.name}"/></tr> </table> </div> <div th:if="${currentSkills == null}"> You don't have any

Thymeleaf with Spring Security - how to check if user is logged in or not?

吃可爱长大的小学妹 提交于 2021-02-05 20:27:03
问题 I'm using Spring Boot with Thymeleaf and Spring Security. I've got a simple view with a login link. When the user logs in, I'd like to change login link to logout link. I tried: <div sec:authorize="#{isAuthenticated()}"> <a th:href="@{/logout}">Log out</a> </div> <div sec:authorize="#{isAnonymous()}"> <a th:href="@{/login}">Log in</a> </div> but it's not working - it displays both links. Best regards. EDIT: I solved it. I had to register Thymeleaf dialect. In order to do this, I created a new

Thymeleaf with Spring Security - how to check if user is logged in or not?

前提是你 提交于 2021-02-05 20:19:26
问题 I'm using Spring Boot with Thymeleaf and Spring Security. I've got a simple view with a login link. When the user logs in, I'd like to change login link to logout link. I tried: <div sec:authorize="#{isAuthenticated()}"> <a th:href="@{/logout}">Log out</a> </div> <div sec:authorize="#{isAnonymous()}"> <a th:href="@{/login}">Log in</a> </div> but it's not working - it displays both links. Best regards. EDIT: I solved it. I had to register Thymeleaf dialect. In order to do this, I created a new

Thymeleaf with Spring Security - how to check if user is logged in or not?

北城余情 提交于 2021-02-05 20:18:57
问题 I'm using Spring Boot with Thymeleaf and Spring Security. I've got a simple view with a login link. When the user logs in, I'd like to change login link to logout link. I tried: <div sec:authorize="#{isAuthenticated()}"> <a th:href="@{/logout}">Log out</a> </div> <div sec:authorize="#{isAnonymous()}"> <a th:href="@{/login}">Log in</a> </div> but it's not working - it displays both links. Best regards. EDIT: I solved it. I had to register Thymeleaf dialect. In order to do this, I created a new

Data tables in Spring Boot thymleaf apps

落爺英雄遲暮 提交于 2021-02-05 09:24:29
问题 How do I add edit and delete columns in this table? Here is my JavaScript code... $(document).ready( function () { var table = $('#employeesTable').DataTable({ "sAjaxSource": "/employees", "sAjaxDataProp": "", "order": [[ 0, "asc" ]], "aoColumns": [ { "mData": "id"}, { "mData": "name" }, { "mData": "capital" }, ] }) }); Here is my HTML page... <table id="employeesTable" class="display"> <thead> <tr> <th>Id</th> <th>Name</th> <th>Capital</th> </tr> </thead> </table> 来源: https://stackoverflow