Calculator using Thymeleaf

Calculator Project (Arithmetic operation) 1.Create New Starter Project 2.Add Spring web, thymeleaf and spring development tools dependencies 3.Create separate package for controller class. The package name should be com.example.demo.controller 4.Add Controller class in this package. Import necessary packages if needed. 5.When we give localhost:8080/- This web browser request goes to controller class first. Finds mapping (GetMapping(“/”)) . Controller class 6.Create calc.html under templates in src/main/resources folder. 7.Added css in head section as a internal css 8.Now html got input from user have to send them to controller class for processing. @RequestParam annotation is used to get values from browser. When the form is submitted it goes to map with calculated. For this PostMapping() is used. 9.It returns value in the same calc.html. 10.Console SPRING is changed to CALCULATOR . Include banner.txt in templates folder. 11.https://patorjk.com/software/taag/#p=display&f=Big&t=hello%0A Use this link for changing text to ASCII text. And paste this ASCII text in banner.txt. We can add version, owner here. Add “version=Calculator v 1.0” in application.properties. 12.We have to give two numbers and select operation and hit calculate button will get result. Final output page: List of dependencies used in these project: Thymeleaf Spring development tools Spring web List of Annotations used in these project: @Controller @GetMapping() @PostMapping() @RequestParam()

Apr 10, 2025 - 22:05
 0
Calculator using Thymeleaf

Calculator Project (Arithmetic operation)
1.Create New Starter Project
2.Add Spring web, thymeleaf and spring development tools dependencies
3.Create separate package for controller class. The package name should be com.example.demo.controller
4.Add Controller class in this package. Import necessary packages if needed.
5.When we give localhost:8080/- This web browser request goes to controller class first. Finds mapping (GetMapping(“/”)) .
Controller class

Image description
6.Create calc.html under templates in src/main/resources folder.

Image description
7.Added css in head section as a internal css

Image description
8.Now html got input from user have to send them to controller class for processing. @RequestParam annotation is used to get values from browser. When the form is submitted it goes to map with calculated. For this PostMapping() is used.

Image description
9.It returns value in the same calc.html.
10.Console SPRING is changed to CALCULATOR . Include banner.txt in templates folder.
11.https://patorjk.com/software/taag/#p=display&f=Big&t=hello%0A
Use this link for changing text to ASCII text. And paste this ASCII text in banner.txt. We can add version, owner here. Add “version=Calculator v 1.0” in application.properties.

Image description
12.We have to give two numbers and select operation and hit calculate button will get result.
Final output page:

Image description

List of dependencies used in these project:
Thymeleaf
Spring development tools
Spring web

List of Annotations used in these project:
@Controller
@GetMapping()
@PostMapping()
@RequestParam()