Skip to content

Commit

Permalink
Implemented JokeeController. Closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhDatar committed Dec 10, 2022
1 parent ff43929 commit 9c91476
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.springframework.spring5jokesappv2.controllers;

import com.springframework.spring5jokesappv2.services.JokeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class JokeController {
private final JokeService jokeService;
@Autowired
public JokeController(JokeService jokeService) {
this.jokeService = jokeService;
}
@RequestMapping({"/",""})
public String showJoke(Model model){
model.addAttribute("joke", jokeService.getJoke());
return "index";
}
}

0 comments on commit 9c91476

Please sign in to comment.