JAVA-32067 Upgrade spring thymeleaf to spring boot 3 (#16129)
This commit is contained in:
parent
0f5e34ea63
commit
d21e80d93d
|
@ -9,9 +9,9 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<artifactId>parent-boot-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
<relativePath>../../parent-boot-3</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -23,7 +23,7 @@ public class DinoController {
|
|||
model.addAttribute("dinos", dinos);
|
||||
System.out.println(dinos);
|
||||
|
||||
return "templates-3/index";
|
||||
return "index";
|
||||
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class DinoController {
|
|||
|
||||
model.addAttribute("dinos", new Dino());
|
||||
|
||||
return "templates-3/form";
|
||||
return "form";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.baeldung.thymeleaf.mvcdata;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
|
@ -41,21 +41,6 @@ public class EmailController {
|
|||
return "mvcdata/email-request-parameters";
|
||||
}
|
||||
|
||||
@GetMapping("/email/sessionattributes")
|
||||
public String emailSessionAttributes(HttpSession httpSession) {
|
||||
httpSession.setAttribute("emaildata", emailData);
|
||||
return "mvcdata/email-session-attributes";
|
||||
}
|
||||
|
||||
@GetMapping("/email/servletcontext")
|
||||
public String emailServletContext() {
|
||||
servletContext.setAttribute("emailsubject", emailData.getEmailSubject());
|
||||
servletContext.setAttribute("emailcontent", emailData.getEmailBody());
|
||||
servletContext.setAttribute("emailaddress", emailData.getEmailAddress1());
|
||||
servletContext.setAttribute("emaillocale", emailData.getEmailLocale());
|
||||
return "mvcdata/email-servlet-context";
|
||||
}
|
||||
|
||||
@GetMapping("/email/beandata")
|
||||
public String emailBeanData() {
|
||||
return "mvcdata/email-bean-data";
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<body>
|
||||
<h1>Subject</h1>
|
||||
<p th:text="${#servletContext.getAttribute('emailsubject')}"></p>
|
||||
<h1>Content</h1>
|
||||
<p th:text="${#servletContext.getAttribute('emailcontent')}"></p>
|
||||
<h1>Email address</h1>
|
||||
<p th:text="${#servletContext.getAttribute('emailaddress')}"></p>
|
||||
<h1>Language</h1>
|
||||
<p th:text="${#servletContext.getAttribute('emaillocale')}"></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,14 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<body>
|
||||
<h1>Subject</h1>
|
||||
<p th:text="${session.emaildata.emailSubject}"></p>
|
||||
<h1>Content</h1>
|
||||
<p th:text="${session.emaildata.emailBody}"></p>
|
||||
<h1>Email address</h1>
|
||||
<p th:text="${session.emaildata.emailAddress1}"></p>
|
||||
<h1>Language</h1>
|
||||
<p th:text="${#session.getAttribute('emaillocale')}"></p>
|
||||
</body>
|
||||
</html>
|
|
@ -10,8 +10,5 @@
|
|||
<div th:if="${param.query != null}">
|
||||
<p th:text="${param.query[0]}" th:unless="${param.query == null}"></p>
|
||||
</div>
|
||||
<div th:if="${#request.getParameter('query') != null}">
|
||||
<p th:text="${#request.getParameter('query')}" th:unless="${#request.getParameter('query') == null}"></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -48,20 +48,6 @@ public class EmailControllerUnitTest {
|
|||
.andExpect(content().string(containsString("en-US")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallSessionAttributes_thenReturnEmailData() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/email/sessionattributes"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("Good morning !")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallServletContext_thenReturnEmailData() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/email/servletcontext"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("jhon.doe@example.com")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallBeanData_thenReturnEmailData() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/email/beandata"))
|
||||
|
|
Loading…
Reference in New Issue