background color change using spring boot mini project

1) File –> New –> Spring Starter Project
2) Name –> Calculator
3) Select Maven as Type
4) Click Next
5) Add Dependencies: DevTools, Web, Thymeleaf
6) Click Next, Finish
7) Go to src/main/java –> Create a package called com.example.demo….


This content originally appeared on DEV Community and was authored by V I N O T H

1) File --> New --> Spring Starter Project
2) Name --> Calculator
3) Select Maven as Type
4) Click Next
5) Add Dependencies: DevTools, Web, Thymeleaf
6) Click Next, Finish
7) Go to src/main/java --> Create a package called com.example.demo.controller
8) Now, right click the newly created package.

package com.example.demo.controller;


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 Color_controller {

    @GetMapping("/")
    public String change_color(@RequestParam(defaultValue = "blue") String colors, Model model)
    {
        model.addAttribute("selectedColor", colors);
        return "color"; 
    }

}
<!DOCTYPE html>
<html xmlns:th="http://www.thymelear.org">
    <head>
        <title> Color Picker </title>
    </head>
<body th:style="'background-color:' + ${selectedColor}">
        <form action="/" method="get">
            <input type="color" th:value='${selectedColor}' name="colors">
            <input type="submit" value="Change Color">
        </form>

    </body>
</html>

OUTPUT

Image description


This content originally appeared on DEV Community and was authored by V I N O T H


Print Share Comment Cite Upload Translate Updates
APA

V I N O T H | Sciencx (2025-04-15T17:35:10+00:00) background color change using spring boot mini project. Retrieved from https://www.scien.cx/2025/04/15/background-color-change-using-spring-boot-mini-project/

MLA
" » background color change using spring boot mini project." V I N O T H | Sciencx - Tuesday April 15, 2025, https://www.scien.cx/2025/04/15/background-color-change-using-spring-boot-mini-project/
HARVARD
V I N O T H | Sciencx Tuesday April 15, 2025 » background color change using spring boot mini project., viewed ,<https://www.scien.cx/2025/04/15/background-color-change-using-spring-boot-mini-project/>
VANCOUVER
V I N O T H | Sciencx - » background color change using spring boot mini project. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/04/15/background-color-change-using-spring-boot-mini-project/
CHICAGO
" » background color change using spring boot mini project." V I N O T H | Sciencx - Accessed . https://www.scien.cx/2025/04/15/background-color-change-using-spring-boot-mini-project/
IEEE
" » background color change using spring boot mini project." V I N O T H | Sciencx [Online]. Available: https://www.scien.cx/2025/04/15/background-color-change-using-spring-boot-mini-project/. [Accessed: ]
rf:citation
» background color change using spring boot mini project | V I N O T H | Sciencx | https://www.scien.cx/2025/04/15/background-color-change-using-spring-boot-mini-project/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.