All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockserver.examples.proxy.web.controller.BooksPageController Maven / Gradle / Ivy

There is a newer version: 5.15.0
Show newest version
package org.mockserver.examples.proxy.web.controller;

import org.mockserver.examples.proxy.service.BookService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * @author jamesdbloom
 */
@Controller
public class BooksPageController {

    @Resource
    private BookService bookService;

    @RequestMapping(value = "/books", method = RequestMethod.GET)
    public String getBookList(Model model) {
        model.addAttribute("books", bookService.getAllBooks());
        return "books";
    }

    @RequestMapping(value = "/book/{id}", method = RequestMethod.GET)
    public String getBook(@PathVariable String id, Model model) {
        model.addAttribute("book", bookService.getBook(id));
        return "book";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy