thymeleaf

Thymeleaf form not submitting to Spring boot controller

人盡茶涼 提交于 2021-01-29 07:12:55
问题 I am trying to submit a form to Spring boot controller This is the thymeleaf part: <form th:action="@{/change_password}" method="post"> <div class="row"> <div class="col-md-9 register-right"> <div class="tab-content" id="myTabContent"> <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab"> <h3 class="register-heading">Change password</h3> <div class="row register-form"> <div class="col-md-6"> <div class="form-group"> <input type="email" th:name="email" id

Using thymeleaf to post form data to a Controller that uses @ModelAttribute (complex objects)

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 04:16:16
问题 There is the Element class: public class Element { private Long id; private Name name; // Getters and Setters ... } And the Name class: public class Name { private String en; private String fr; private String de; // Getters and Setters ... } There is a getElementsController: @GetMapping("/elements/create") public String getElementsCreate() { return "private/new-element"; } There is a NewElementController controller: @PostMapping("/elements/create") public String postElementsCreate(

How to do a if else in thymeleaf inside a loop that populate a table

大城市里の小女人 提交于 2021-01-29 04:07:40
问题 I'm populating a table using a <tr th:each> and I want to put a if statement that evaluates the value if it is null, if the values is null I want to put this "--" instead of "null". How can I do this using the th:if or other similar function I am new using thymeleaf? This is my code: <table id="datatable_fixed_column" class="table table-striped table-bordered" width="100%"> <thead> <tr> <th>name</th> <th>lastname</th> <tr> <tbody> <tr th:each="nodeInfo : ${listOfData}"> <td th:if="${nodeInfo

How to disable csrf protection for particular pages in my website?

主宰稳场 提交于 2021-01-28 22:18:53
问题 CSRF protection is used so that any requests made from other websites cannot affect my website to cause harm. It is said in the spring security csrf documentation that csrf is applied for put post patch delete requests. But according to my understanding, login/signup forms do not need csrf protection, as they already require credentials in the form of username and password and even if such a request is made from another website, there will be no harm as the user will just get logged in. But

spring boot security static resources

落爺英雄遲暮 提交于 2021-01-28 22:00:42
问题 I write app in Spring Boot, Spring Security with Thymeleaf and I try to get access my static resource file... This is my project structure... . ├── mvnw ├── mvnw.cmd ├── nb-configuration.xml ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ ├── resources │ │ │ ├── application.properties │ │ │ ├── static | | | | |---------------------------------this is image.jpg │ │ │ ├── templates │ │ │ └── ValidationMessages.properties │ │ └── wro │ │ ├── css │ │ ├── fonts │ │ ├── js │ │ ├──

Thymeleaf iteration over list of objects

試著忘記壹切 提交于 2021-01-28 19:22:40
问题 I have a problem, while I am iterating over a list of object in Thymeleaf. Here is my HTML: <input th:each="a,iterStatus : currentQuestion.answers" type="radio" name="answer" th:text="${a.answer}" th:value="${iterStatus.index}"></input> Here is Controller class: @RequestMapping(value={ "/exam", "/exam/" }, method = RequestMethod.GET) public String exam(Model model){ if (!sessionPreferences.isExamStarted()){ sessionPreferences.setQuestionList(questionService.list(Questions.findAll().paginate(0

Thymeleaf iteration over list of objects

纵饮孤独 提交于 2021-01-28 18:27:54
问题 I have a problem, while I am iterating over a list of object in Thymeleaf. Here is my HTML: <input th:each="a,iterStatus : currentQuestion.answers" type="radio" name="answer" th:text="${a.answer}" th:value="${iterStatus.index}"></input> Here is Controller class: @RequestMapping(value={ "/exam", "/exam/" }, method = RequestMethod.GET) public String exam(Model model){ if (!sessionPreferences.isExamStarted()){ sessionPreferences.setQuestionList(questionService.list(Questions.findAll().paginate(0

How to add default values to input fields in Thymeleaf

时光毁灭记忆、已成空白 提交于 2021-01-28 15:00:50
问题 I am programming in Spring and using Thymeleaf as my view, and am trying to create a form where users can update their profile. I have a profile page which lists the user's information (first name, last name, address, etc), and there is a link which says "edit profile". When that link is clicked it takes them to a form where they can edit their profile. The form consists of text fields that they can input, just like your standard registration form. Everything works fine, but my question is,

How to add default values to input fields in Thymeleaf

会有一股神秘感。 提交于 2021-01-28 14:57:55
问题 I am programming in Spring and using Thymeleaf as my view, and am trying to create a form where users can update their profile. I have a profile page which lists the user's information (first name, last name, address, etc), and there is a link which says "edit profile". When that link is clicked it takes them to a form where they can edit their profile. The form consists of text fields that they can input, just like your standard registration form. Everything works fine, but my question is,

thymeleaf show top-k rows of a table

和自甴很熟 提交于 2021-01-28 05:44:25
问题 I have a table and a multiline dataset. I do not want to span all the rows of this table. So I created a counter but I get an error at the if condition: <div th:if="${dataset}" th:with="counter=0"> <table class="table"> <tbody> <th:block th:each="t_log : ${dataset.rows}" th:with="counter=${counter} + 1"> <tr th:if="${counter <= 5 }"> <td th:text="${t_log.title}"/> <td th:if="${t_log.msg == '1'}" th:text="Online"/> <td th:if="${t_log.msg == '0'}" th:text="Offline"/> </tr> </th:block> </tbody>