From 38be954b01e3a763dfbf99e50db2d6555937e1d0 Mon Sep 17 00:00:00 2001 From: ACHRAF TAITAI <43656331+achraftt@users.noreply.github.com> Date: Sun, 25 Sep 2022 20:06:25 +0200 Subject: [PATCH] Getting URL Attribute Value in Thymeleaf (#12766) --- .../baeldung/thymeleaf/url/UrlController.java | 13 +++++++++++++ .../src/main/resources/templates/url/index.html | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/url/UrlController.java create mode 100644 spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/url/index.html diff --git a/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/url/UrlController.java b/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/url/UrlController.java new file mode 100644 index 0000000000..be96be5a33 --- /dev/null +++ b/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/url/UrlController.java @@ -0,0 +1,13 @@ +package com.baeldung.thymeleaf.url; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Controller +public class UrlController { + @GetMapping("/search") public String test(Model model, @RequestParam("query") String query){ + return "url/index"; + } +} diff --git a/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/url/index.html b/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/url/index.html new file mode 100644 index 0000000000..a8ac95aea3 --- /dev/null +++ b/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/url/index.html @@ -0,0 +1,17 @@ + + +
+ + + +