Spring MVC Hands On BMI Calculator: Important Instructions
Spring MVC Hands On BMI Calculator: Important Instructions
Important Instructions:
Assessment Coverage:
A leading XYZ Finance Company decided to provide service through online for customer. This
Portal has to provide various services. BMI stands for Body Mass Index. It is a measure of body
mass based on height and weight of an individual. One of the services is BMI Calculator. The
customer can use this portal to calculate BMI .Using the range of BMI, individuals are classified
as underweight, normal or overweight. Its value is in a specific range for a healthy individual.
The following table shows the main BMI categories.
Create Web application to calculates BMI value based on inputs in metric units. The
BMICalc Service web application aims at the following features
1. Calculate BMI by providing user details and add the user details to
collection.
2. View the BMI status after successful calulation.
Spring MVC Hands On BMI Calculator
Import the below attached skeleton code into your eclipse project and implement the required
functionalities
Data Design
This project currently does not connect with the DB server and therefore uses the in-memory
storage using java collections (HashMap) to perform read/write operations related to the
scope of the application.
Component Design
Component name: src/main/webapp/WEB-INF/views/bmiCalculatorForm.jsp
Description: This JSP is used by the user to calculate their BMI. The URL for this page is /bmiForm
which has to be launched from the browser’s address bar which means that it is a HTTP GET request.
The page looks something similar to the image shown below.
All the labels are created as per the above page. The following table provides the more information
about the above image.
genderType Drop genderType This field lists the gender types . User can
down select their gender type from the dropdown
list.
"calculateBMI" Submit "calculateBMI" When this button is clicked, the URL that has to
(should be name be executed is /getBMI which is the declared in
and not id) the action attribute of <form> tag. The type of
the http method is GET. This URL has to be
mapped to getBMIStatus
getBMIStatus(@ModelAttribute("user")
@Valid User user, BindingResult result,
ModelMap map) method of the UserController
class
Cancel reset This button is used to reset the data
Note: The values in the Gender drop-down must be auto populated from the controller with the
values as given in the below table. They should not be populated/hardcoded inside the JSP.
GenderType
Male
Female
Others
Component Name: src/main/webapp/WEB-INF/views/bmiStatus.jsp
Description: This page displays user bmi status information, when all the details entered are
added to collection successfully; it should print the message in h2 tag. And h2 tag id should be
“status”
Technical Requirements:
Attributes Method
userId : int getter/setter
name: String
phoneNumber: String
height: Integer
weight: Double
genderType: String
In this class constructor adds the data into genderType attribute. The following table gender
type information here.
GenderType
Male
Female
Others
This class provides addUserDetails method which is used add the user data into in the
collection.
UserController
Attribute Name Attribute Type Access Specifier Constraints
bmiService BMIService Private Use annotation to
autowire
This file is used to configure various properties such as prefix and suffix of view resolvers, server port
etc. so, please declare all the properties as required by the application in this file.