Skip to content

Sienna-Hu/spring5-jokes-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Joke Web Application

This Spring Boot web application displays a random Chuck Norris Joke on the index.

image

Detail Description

Following the instructions of an online course about Spring Framework 5 on Udemy, I build this toy web application. It contains a Spring Service Layer (JokeService & JokeServiceimpl), a Spring MVC Controller (JokeController) and a View Layer (insides resources/templates).

The building steps go as following:

  1. Create Spring Boot Project from Spring Initializr (add 'Web' and 'Thymeleaf' dependencies)
  2. Add new Dependency: group: 'guru.springframework', name: 'chuck-norris-for-actuator', version: '0.0.2'
  3. Create Spring Service Layer:
    1. The Service returns a random joke string from ChuckNorrisQuotes.getRandomQuote()
  4. Create the Spring MVC Controller:
    1. Map context root ("/", "") to Jokes view
    2. Add the joke generated by Service to 'joke' property of Model (model.addAttribute("joke", jokeService.getJoke()))
    3. Return view name of 'chucknorris'
  5. Create the View Layer

What I learned

Through building this application, I gained some basic understandings of MVC and SpringFramework:

  • When the client makes a request (for a webpage here), the Controller gets the Model (through the wired up Service layer) and returns the Model to the View.

About

This Spring Boot web application displays a random Chuck Norris Joke on the index.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published