DEV Community

V I N O T H
V I N O T H

Posted on • Edited on

1 1 1 1 1

Registration Form Application in Spring boot java

*Registration From Application *

1.controller

package com.example.demo;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class Regn_controller {

    @GetMapping("/")
    public String display(Model model)
    {
    model.addAttribute("genders", List.of("Male","Female","Other"));
    model.addAttribute("countries", List.of("Japan","U.S","Londan"));
    model.addAttribute("hobbies", List.of("Football","Cricket","GYM"));
        return "register"; 
    }

    @PostMapping("registered")
    public String getDetails(@RequestParam String username,
            @RequestParam String gene,
            Model model)
    {
        model.addAttribute("name", username);
        model.addAttribute("gend", gene);
        return "success"; 
    }
}   
Enter fullscreen mode Exit fullscreen mode

2.Register.html

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <title> Registration Form</title>

    </head>
    <body>
        <form action="registered" method="post">
        <label> Name: </label> 
        <input type="text" name="username" placeholder="Enter Your Name" required>
        <br><br>
        <label> Gender: </label>
        <input type="radio" name="gene"
         th:each="gender:${genders}" th:value="${gender}" th:text="${gender}">
        <br><br>
        <label> Country: </label>
        <select name="nation">
<option th:each="country:${countries}" th:value="${country}" 
th:text="${country}">

            </option>
        </select>
        <br><br>
        <label> Hobby: </label>

        <input type="checkbox" name="hob" 
        th:each="hobby:${hobbies}" th:value="${hobby}" 
        th:text="${hobby}">
        <br><br>
        <input type="submit" value="Enter Details">
        </form>
    </body>


</html>
Enter fullscreen mode Exit fullscreen mode

3.Success.html

Registered Successfully
<p th:text="${name}">

</p>
<p th:text="${gend}">

</p>
Enter fullscreen mode Exit fullscreen mode

OUTPUT

Image description

Image description

Warp.dev image

The best coding agent. Backed by benchmarks.

Warp outperforms every other coding agent on the market, and gives you full control over which model you use. Get started now for free, or upgrade and unlock 2.5x AI credits on Warp's paid plans.

Download Warp

Top comments (1)

Collapse
 
vinoth_124 profile image
V I N O T H

keep doing this bro

AWS Q Developer image

Build your favorite retro game with Amazon Q Developer CLI in the Challenge & win a T-shirt!

Feeling nostalgic? Build Games Challenge is your chance to recreate your favorite retro arcade style game using Amazon Q Developer’s agentic coding experience in the command line interface, Q Developer CLI.

Participate Now

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay