SlideShare a Scribd company logo
Java Spring MVC using
MySQL
What are we building?
• A MVC webapplikation for CRUD operations
Webapp CRUD operations
What we need to create this app
• MySql Database
• Spring Initializr to set up the Spring webapp
Create account and database at
https://remotemysql.com/
• Create tables in phpmyadmin
• https://www.liquidweb.com/kb/creating-tables-in-a-database-with-
phpmyadmin/
NB-Springboot-Plugins for netbeans 11/12
• http://plugins.netbeans.org/plugin/67888/nb-springboot
• https://github.com/AlexFalappa/nb-springboot/wiki/Quick-Tour
• https://www.techgalery.com/2019/01/how-to-create-spring-boot-
project-using.html
From meny Tools/
plugins
Spring initializr
• Got to https://start.spring.io/
• Add these dependencies so we can create a spring web app and database connection
rename
Move the download zip file to more suitable
folder
Open netbeans import the zip file
• Import the saved zip file in netbeans File->import->from zip
• Will be a new project.
Intro Spring creating Controllers and Views
1. Any incoming request that comes to the web
application will be sent to Front Controller (a
Dispatcher Servlet)
2. Front Controller decides to which (Controller) it has to
hand over the request, based on the request headers.
3. Controller that took the request, processes the
request, by sending it to suitable service class.
4. After all processing is done, Controller receives the
model from the Service or Data Access layer.
5. Controller sends the model to the Front Controller
6. Dispatcher servlet finds the view template, using view
resolver and send the model to it.
7. Using View template and the model a view page is
build and sent back to the Front Controller.
8. Front controller sends the constructed view page to
the browser to render it for the user requested.
Create package for our controllers and then
add a CarControllerMysql
• Create an controllers package
• Name it controllers
• Add new java Controller class in that package
• Name it CarControllerMysql
To see this Controller class
you need the plugin for
NB-springboot installed
The auto genereted code for the new
TestController class
Run the web app,
you get an error about databases
Run the app, this is where the main method is
Need to add database properties to fix the
error
• Open application.properties. Then add these properties, but use your
credentials that you got from for remotemysql.com
Stop and run the webapp again and it works
Run the app, this is where the main method is
Surf to localhost:8080/
Surf to localhost:8080
• You get this error because we haven’t mapped a Controller to handle
this request,
• But we have the CarControllerMysql how can we use that
But we have the CarControllerMysql
• How can we use it? It handle the request for a ”/url”
It handle the request for ”/url” try this
localhost:8080/url
Same error?? Why? We need a view
The problem is the view
We should have a mustche view that contains html to be
shown when we surf to this request localhost:8080/url
Create a mustache view under templates
Use .mustache as file type
Add html to the urlview.mustache
Change in the CarControllerMysql
Change here to match the new urlview.
No need for .mustache as file type here
Stop and run the app again
• surf to localhost:8080/url se how the urlview.msutcha is presente
Shows the urlview.mustache
How to use the Model to set data to be
shown in view
• After all these changes stop and run the app again.
Change to this.
We will use the key ”attribute”
in the urlview to show the text ”Hello world value”
We have the controller, the model and the
view
urlview.mustache
Using request parameters in url
localhost:8080/url?name=Stina
Manage the request parameter name
Set attribute key ”yourname” and it’s value, to show the name in th
Urlview using the attribute key ”yourname”
Create requestaparameter
Using @PathVariable in url
localhost:8080/url/20
Set attribute key and value, to show in urlview
Manage PathVariables
Set defaultValue
For requestparameter
Create PathVariable id in url, using {id}
Stop and run the app
• Test the url using pathvariable and pathvariable+requestparameter
Funkar inte
Using arrays
• Create new @RequestMapping
method
• Create new view,
linksview.mustache
Use dot to get string
element
Start loop
End loop
Stop and run the app again, surf to
localhost:8080/url/links
Use Lists
Create List
and add cars
Use key attribute cars in linksview
Create loop to show id regnr of cars in the list
Stop and run the app again, surf to
localhost:8080/url/links
Our cars
Example slideshow
Create Controller - SlideShowController
Surf to localhost:8080/slideshow
you’re redirect to slideshow/next
Show the view
Set model data to be shown in the view
counter and picture
SlideShowController continue
Set model data to be shwon in the view
Decreament counter to show prev picture from array.
And check it’s bounds, we don’t won’t to have a
ArrayIndexOutOfBounds Exception
Show the view
Create View- slideshow.mustache
picture and counter was sett as model
data in the controller
Form handling
Create Controller –FormController.java
Handles the Posted data
from the form
Shows the form
Show view
Contains posted data;
name of form gui
components
and it’s filled in values
Create a view to show form
-userform.mustache
action=Which postmapping in controller
that handles the posted form data
name attribute is used in
the RequestParam in Controller to get
data from the is particular textfield
userform.mustache- cont
Submit the form to the controller
,which url or postmapping is state in
forms action attribute; action=”/formhandling”
View that show the posted form data-
userformhandling.mustache
Using the keys that where set in the controller based on
posted requestparam from the form.

More Related Content

What's hot

How to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaHow to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmia
Roy Sivan
 
Building WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmiaBuilding WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmia
Roy Sivan
 
Integrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azureIntegrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azure
Son Nguyen
 
DevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time EngineDevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time Engine
Ronny Trommer
 
Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.net
Sireesh K
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
Jason Noble
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con python
sserrano44
 
Markdown tutorial how to add markdown to rails app using redcarpet and codera...
Markdown tutorial how to add markdown to rails app using redcarpet and codera...Markdown tutorial how to add markdown to rails app using redcarpet and codera...
Markdown tutorial how to add markdown to rails app using redcarpet and codera...
Katy Slemon
 
Rails engine
Rails engineRails engine
Rails engine
Jyaasa Technologies
 
Catalog display
Catalog displayCatalog display
Catalog display
Jason Noble
 
Ruby on rails3 - introduction to rails
Ruby on rails3 - introduction to railsRuby on rails3 - introduction to rails
Ruby on rails3 - introduction to rails
Emad Elsaid
 
Rails engines
Rails enginesRails engines
Rails engines
Josh Schramm
 
Quick Way to work with Models and Alloy in Appcelerator Titanium
Quick Way to work with Models and Alloy in Appcelerator TitaniumQuick Way to work with Models and Alloy in Appcelerator Titanium
Quick Way to work with Models and Alloy in Appcelerator Titanium
Aaron Saunders
 
Introduction To Asp.Net Ajax
Introduction To Asp.Net AjaxIntroduction To Asp.Net Ajax
Introduction To Asp.Net Ajax
Jeff Blankenburg
 
One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"
testflyjets
 
Deploy with maven
Deploy with mavenDeploy with maven
Deploy with maven
Son Nguyen
 
Ember components
Ember componentsEmber components
Ember components
Sarath Chandra
 
RBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails AppRBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails App
ameedahc
 
Active Admin
Active AdminActive Admin
Active Admin
Greg Bell
 
Quality Code With Cucumber Presentation
Quality Code With Cucumber PresentationQuality Code With Cucumber Presentation
Quality Code With Cucumber Presentation
railsconf
 

What's hot (20)

How to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaHow to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmia
 
Building WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmiaBuilding WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmia
 
Integrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azureIntegrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azure
 
DevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time EngineDevJam 2019 - Building an ALEC Time Engine
DevJam 2019 - Building an ALEC Time Engine
 
Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.net
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con python
 
Markdown tutorial how to add markdown to rails app using redcarpet and codera...
Markdown tutorial how to add markdown to rails app using redcarpet and codera...Markdown tutorial how to add markdown to rails app using redcarpet and codera...
Markdown tutorial how to add markdown to rails app using redcarpet and codera...
 
Rails engine
Rails engineRails engine
Rails engine
 
Catalog display
Catalog displayCatalog display
Catalog display
 
Ruby on rails3 - introduction to rails
Ruby on rails3 - introduction to railsRuby on rails3 - introduction to rails
Ruby on rails3 - introduction to rails
 
Rails engines
Rails enginesRails engines
Rails engines
 
Quick Way to work with Models and Alloy in Appcelerator Titanium
Quick Way to work with Models and Alloy in Appcelerator TitaniumQuick Way to work with Models and Alloy in Appcelerator Titanium
Quick Way to work with Models and Alloy in Appcelerator Titanium
 
Introduction To Asp.Net Ajax
Introduction To Asp.Net AjaxIntroduction To Asp.Net Ajax
Introduction To Asp.Net Ajax
 
One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"
 
Deploy with maven
Deploy with mavenDeploy with maven
Deploy with maven
 
Ember components
Ember componentsEmber components
Ember components
 
RBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails AppRBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails App
 
Active Admin
Active AdminActive Admin
Active Admin
 
Quality Code With Cucumber Presentation
Quality Code With Cucumber PresentationQuality Code With Cucumber Presentation
Quality Code With Cucumber Presentation
 

Similar to Java spring mysql without hibernate(2) (1)

ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
 
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIsCustom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs
Akhil Mittal
 
How to develop a gateway service using code based implementation
How to develop a gateway service using code based implementationHow to develop a gateway service using code based implementation
How to develop a gateway service using code based implementation
nitin2517
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
Dev_Events
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
Yochay Kiriaty
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
Marcio Marinho
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Vivek chan
 
294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application
Faina Fridman
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
Eric Wise
 
Lecture 4_Laravel Controller and Data Pass-Route.pptx
Lecture 4_Laravel Controller and Data Pass-Route.pptxLecture 4_Laravel Controller and Data Pass-Route.pptx
Lecture 4_Laravel Controller and Data Pass-Route.pptx
SaziaRahman
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplified
Vikas Singh
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Maarten Balliauw
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
Damien Krotkine
 
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerE2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
Paul Jensen
 
Ruby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraRuby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybara
Andolasoft Inc
 
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JSFestUA
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
Volkan Uzun
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen
 

Similar to Java spring mysql without hibernate(2) (1) (20)

ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIsCustom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs
 
How to develop a gateway service using code based implementation
How to develop a gateway service using code based implementationHow to develop a gateway service using code based implementation
How to develop a gateway service using code based implementation
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
 
Lecture 4_Laravel Controller and Data Pass-Route.pptx
Lecture 4_Laravel Controller and Data Pass-Route.pptxLecture 4_Laravel Controller and Data Pass-Route.pptx
Lecture 4_Laravel Controller and Data Pass-Route.pptx
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplified
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerE2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
 
Ruby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraRuby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybara
 
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 

Recently uploaded

The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdfThe 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
thesiliconleaders
 
How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...
How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...
How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...
Aleksey Savkin
 
2022 Vintage Roman Numerals Men Rings
2022 Vintage Roman  Numerals  Men  Rings2022 Vintage Roman  Numerals  Men  Rings
2022 Vintage Roman Numerals Men Rings
aragme
 
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
AnnySerafinaLove
 
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
my Pandit
 
Creative Web Design Company in Singapore
Creative Web Design Company in SingaporeCreative Web Design Company in Singapore
Creative Web Design Company in Singapore
techboxsqauremedia
 
Easily Verify Compliance and Security with Binance KYC
Easily Verify Compliance and Security with Binance KYCEasily Verify Compliance and Security with Binance KYC
Easily Verify Compliance and Security with Binance KYC
Any kyc Account
 
Chapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .pptChapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .ppt
ssuser567e2d
 
Satta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel Chart
Satta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel ChartSatta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel Chart
Satta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel Chart
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
SOFTTECHHUB
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
FelixPerez547899
 
BeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdfBeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdf
DerekIwanaka1
 
Understanding User Needs and Satisfying Them
Understanding User Needs and Satisfying ThemUnderstanding User Needs and Satisfying Them
Understanding User Needs and Satisfying Them
Aggregage
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
JeremyPeirce1
 
Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431
ecamare2
 
3 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 20243 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 2024
SEOSMMEARTH
 
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your TasteZodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
my Pandit
 
Best practices for project execution and delivery
Best practices for project execution and deliveryBest practices for project execution and delivery
Best practices for project execution and delivery
CLIVE MINCHIN
 
amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05
marketing317746
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
Kirill Klimov
 

Recently uploaded (20)

The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdfThe 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
 
How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...
How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...
How to Implement a Strategy: Transform Your Strategy with BSC Designer's Comp...
 
2022 Vintage Roman Numerals Men Rings
2022 Vintage Roman  Numerals  Men  Rings2022 Vintage Roman  Numerals  Men  Rings
2022 Vintage Roman Numerals Men Rings
 
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
 
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
 
Creative Web Design Company in Singapore
Creative Web Design Company in SingaporeCreative Web Design Company in Singapore
Creative Web Design Company in Singapore
 
Easily Verify Compliance and Security with Binance KYC
Easily Verify Compliance and Security with Binance KYCEasily Verify Compliance and Security with Binance KYC
Easily Verify Compliance and Security with Binance KYC
 
Chapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .pptChapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .ppt
 
Satta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel Chart
Satta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel ChartSatta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel Chart
Satta Matka Dpboss Matka Guessing Kalyan Chart Indian Matka Kalyan panel Chart
 
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
 
BeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdfBeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdf
 
Understanding User Needs and Satisfying Them
Understanding User Needs and Satisfying ThemUnderstanding User Needs and Satisfying Them
Understanding User Needs and Satisfying Them
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
 
Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431
 
3 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 20243 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 2024
 
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your TasteZodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
 
Best practices for project execution and delivery
Best practices for project execution and deliveryBest practices for project execution and delivery
Best practices for project execution and delivery
 
amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05amptalk_RecruitingDeck_english_2024.06.05
amptalk_RecruitingDeck_english_2024.06.05
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
 

Java spring mysql without hibernate(2) (1)

  • 1. Java Spring MVC using MySQL
  • 2. What are we building? • A MVC webapplikation for CRUD operations
  • 4. What we need to create this app • MySql Database • Spring Initializr to set up the Spring webapp
  • 5. Create account and database at https://remotemysql.com/ • Create tables in phpmyadmin • https://www.liquidweb.com/kb/creating-tables-in-a-database-with- phpmyadmin/
  • 6. NB-Springboot-Plugins for netbeans 11/12 • http://plugins.netbeans.org/plugin/67888/nb-springboot • https://github.com/AlexFalappa/nb-springboot/wiki/Quick-Tour • https://www.techgalery.com/2019/01/how-to-create-spring-boot- project-using.html From meny Tools/ plugins
  • 7. Spring initializr • Got to https://start.spring.io/ • Add these dependencies so we can create a spring web app and database connection rename
  • 8. Move the download zip file to more suitable folder
  • 9. Open netbeans import the zip file • Import the saved zip file in netbeans File->import->from zip • Will be a new project.
  • 10. Intro Spring creating Controllers and Views 1. Any incoming request that comes to the web application will be sent to Front Controller (a Dispatcher Servlet) 2. Front Controller decides to which (Controller) it has to hand over the request, based on the request headers. 3. Controller that took the request, processes the request, by sending it to suitable service class. 4. After all processing is done, Controller receives the model from the Service or Data Access layer. 5. Controller sends the model to the Front Controller 6. Dispatcher servlet finds the view template, using view resolver and send the model to it. 7. Using View template and the model a view page is build and sent back to the Front Controller. 8. Front controller sends the constructed view page to the browser to render it for the user requested.
  • 11. Create package for our controllers and then add a CarControllerMysql • Create an controllers package • Name it controllers • Add new java Controller class in that package • Name it CarControllerMysql To see this Controller class you need the plugin for NB-springboot installed
  • 12. The auto genereted code for the new TestController class
  • 13. Run the web app, you get an error about databases Run the app, this is where the main method is
  • 14. Need to add database properties to fix the error • Open application.properties. Then add these properties, but use your credentials that you got from for remotemysql.com
  • 15. Stop and run the webapp again and it works Run the app, this is where the main method is Surf to localhost:8080/
  • 16. Surf to localhost:8080 • You get this error because we haven’t mapped a Controller to handle this request, • But we have the CarControllerMysql how can we use that
  • 17. But we have the CarControllerMysql • How can we use it? It handle the request for a ”/url” It handle the request for ”/url” try this localhost:8080/url Same error?? Why? We need a view
  • 18. The problem is the view We should have a mustche view that contains html to be shown when we surf to this request localhost:8080/url
  • 19. Create a mustache view under templates Use .mustache as file type
  • 20. Add html to the urlview.mustache Change in the CarControllerMysql Change here to match the new urlview. No need for .mustache as file type here
  • 21. Stop and run the app again • surf to localhost:8080/url se how the urlview.msutcha is presente Shows the urlview.mustache
  • 22. How to use the Model to set data to be shown in view • After all these changes stop and run the app again. Change to this. We will use the key ”attribute” in the urlview to show the text ”Hello world value”
  • 23. We have the controller, the model and the view urlview.mustache
  • 24. Using request parameters in url localhost:8080/url?name=Stina Manage the request parameter name Set attribute key ”yourname” and it’s value, to show the name in th Urlview using the attribute key ”yourname” Create requestaparameter
  • 25. Using @PathVariable in url localhost:8080/url/20 Set attribute key and value, to show in urlview Manage PathVariables Set defaultValue For requestparameter Create PathVariable id in url, using {id}
  • 26. Stop and run the app • Test the url using pathvariable and pathvariable+requestparameter Funkar inte
  • 27. Using arrays • Create new @RequestMapping method • Create new view, linksview.mustache Use dot to get string element Start loop End loop
  • 28. Stop and run the app again, surf to localhost:8080/url/links
  • 29. Use Lists Create List and add cars Use key attribute cars in linksview Create loop to show id regnr of cars in the list
  • 30. Stop and run the app again, surf to localhost:8080/url/links Our cars
  • 32. Create Controller - SlideShowController Surf to localhost:8080/slideshow you’re redirect to slideshow/next Show the view Set model data to be shown in the view counter and picture
  • 33. SlideShowController continue Set model data to be shwon in the view Decreament counter to show prev picture from array. And check it’s bounds, we don’t won’t to have a ArrayIndexOutOfBounds Exception Show the view
  • 34. Create View- slideshow.mustache picture and counter was sett as model data in the controller
  • 36. Create Controller –FormController.java Handles the Posted data from the form Shows the form Show view Contains posted data; name of form gui components and it’s filled in values
  • 37. Create a view to show form -userform.mustache action=Which postmapping in controller that handles the posted form data name attribute is used in the RequestParam in Controller to get data from the is particular textfield
  • 38. userform.mustache- cont Submit the form to the controller ,which url or postmapping is state in forms action attribute; action=”/formhandling”
  • 39. View that show the posted form data- userformhandling.mustache Using the keys that where set in the controller based on posted requestparam from the form.