buildStudents() {
+ if (students.isEmpty()){
+ Student student1 = new Student();
+ student1.setId(1001);
+ student1.setName("John Smith");
+ student1.setGender('M');
+ student1.setPercentage(Float.valueOf("80.45"));
+
+ students.add(student1);
+
+ Student student2 = new Student();
+ student2.setId(1002);
+ student2.setName("Jane Williams");
+ student2.setGender('F');
+ student2.setPercentage(Float.valueOf("60.25"));
+
+ students.add(student2);
+ }
+
+ return students;
+ }
+
+}
diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/js/studentCheck.js b/spring-thymeleaf/src/main/webapp/WEB-INF/js/studentCheck.js
new file mode 100644
index 0000000000..625e0b37e5
--- /dev/null
+++ b/spring-thymeleaf/src/main/webapp/WEB-INF/js/studentCheck.js
@@ -0,0 +1,2 @@
+var count = [[${students.size()}]];
+alert("Number of students in group: " + count);
diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/txt/studentsList.txt b/spring-thymeleaf/src/main/webapp/WEB-INF/txt/studentsList.txt
new file mode 100644
index 0000000000..b27796c6ab
--- /dev/null
+++ b/spring-thymeleaf/src/main/webapp/WEB-INF/txt/studentsList.txt
@@ -0,0 +1,8 @@
+Dear [(${username})],
+
+This is the list of our students:
+[# th:each="s : ${students}"]
+ - [(${s.name})]. ID: [(${s.id})]
+[/]
+Thanks,
+The Baeldung University
\ No newline at end of file
diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/inliningExample.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/inliningExample.html
new file mode 100644
index 0000000000..cd20746c3a
--- /dev/null
+++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/inliningExample.html
@@ -0,0 +1,12 @@
+
+
+
+
+Inlining example
+
+
+ Title of tutorial: [[${title}]]
+ Description: [(${description})]
+
+
\ No newline at end of file
diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html
index c25de9eb17..a894e41e88 100644
--- a/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html
+++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html
@@ -4,6 +4,15 @@
Student List
+
+
Student List
diff --git a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java
index 46a28c3c74..3542571bbc 100644
--- a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java
+++ b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java
@@ -2,8 +2,8 @@ package org.baeldung.security.csrf;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import javax.servlet.Filter;
@@ -59,5 +59,20 @@ public class CsrfEnabledIntegrationTest {
public void addStudentWithCSRF() throws Exception {
mockMvc.perform(post("/saveStudent").contentType(MediaType.APPLICATION_JSON).param("id", "1234567").param("name", "Joe").param("gender", "M").with(testUser()).with(csrf())).andExpect(status().isOk());
}
+
+ @Test
+ public void htmlInliningTest() throws Exception {
+ mockMvc.perform(get("/html").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("inliningExample.html"));
+ }
+
+ @Test
+ public void jsInliningTest() throws Exception {
+ mockMvc.perform(get("/js").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("studentCheck.js"));
+ }
+
+ @Test
+ public void plainInliningTest() throws Exception {
+ mockMvc.perform(get("/plain").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("studentsList.txt"));
+ }
}