Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/srinivas6303/simple-spring-mvc-addition-calculator

A basic Spring MVC project that performs addition of two numbers. Users input two numbers on a form, submit them, and view the result on a new page with an option to return to the input form.
https://github.com/srinivas6303/simple-spring-mvc-addition-calculator

controller css html java jsp-servlet maven spring-boot spring-mvc

Last synced: 17 days ago
JSON representation

A basic Spring MVC project that performs addition of two numbers. Users input two numbers on a form, submit them, and view the result on a new page with an option to return to the input form.

Awesome Lists containing this project

README

        

# Simple Spring MVC Addition Calculator

## Overview
The "Simple Spring MVC Addition Calculator" is a basic calculator project developed using Spring MVC, specifically designed to perform addition of two numbers.

It provides a user interface where users can input two numbers, submit them to the backend, and get the result. The result is displayed on another page, and the user can navigate back to the input form.

## Features
- Add two numbers using a simple form.

- Display the addition result on a new page.

- Basic navigation with a "Back" button.

## Technologies Used
- **Spring Boot** for backend development.

- **Spring MVC** for handling requests and providing the user interface.

- **JSP** for rendering the view pages.

- **HTML/CSS** for styling the front end.

## Project Setup

### Prerequisites
Make sure you have the following installed on your machine:

- **Java 17** or higher
- **Maven**
- **Spring Boot**

### Running the Project
1. Clone the repository:

git clone https://github.com/yourusername/Simple-Spring-MVC-Addition-Calculator.git

2. Navigate to the project directory:

cd Simple-Spring-MVC-Addition-Calculator

3. Build and run the application:

mvn spring-boot:run

4. Open your browser and go to `http://localhost:8080/` to start using the application.

### Project Structure
- **src/main/java/com/example/demo/Calculator.java** - Spring Controller handling the logic for adding numbers.

- **src/main/webapp/index.jsp** - User input page (Enter numbers).

- **src/main/webapp/result.jsp** - Result display page.

### How it Works
1. The user visits the homepage and enters two numbers in the form.

2. When the user clicks the "ADD" button, the `add` method in the `Calculator` controller is invoked.

3. The backend adds the two numbers, and the result is stored in the session.
4. The result is then displayed on a new page (`result.jsp`).

### To Do
- Optionally, add support for other mathematical operations in the future.
- Improve user interface with advanced CSS and layout.
![Screenshot 2025-01-17 185540](https://github.com/user-attachments/assets/0873b35e-9084-47ce-9573-dc1da4e8b78f)
![Screenshot 2025-01-17 185558](https://github.com/user-attachments/assets/bd1b132b-fcdd-4bc9-bb29-54bba2879771)