|
|
@ -6,6 +6,7 @@ import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.ui.Model; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
//import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.web.bind.annotation.ResponseStatus; |
|
|
@ -15,41 +16,47 @@ import org.springframework.web.bind.annotation.ResponseStatus; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
//import javax.validation.Valid; |
|
|
|
|
|
|
|
import com.fjordtek.bookstore.model.Book; |
|
|
|
import com.fjordtek.bookstore.model.*; |
|
|
|
|
|
|
|
@Controller |
|
|
|
public class BookController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static final String landingPageURL = "index"; |
|
|
|
protected static final String bookListPageURL = "booklist"; |
|
|
|
|
|
|
|
private HttpServerLogger httpServerLogger = new HttpServerLogger(); |
|
|
|
private HttpExceptionHandler httpExceptionHandler = new HttpExceptionHandler(); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private BookRepository bookRepository; |
|
|
|
|
|
|
|
@RequestMapping( |
|
|
|
value = landingPageURL, |
|
|
|
value = { bookListPageURL }, |
|
|
|
method = RequestMethod.GET |
|
|
|
) |
|
|
|
public String DefaultWebFormGet(Model dataModel, HttpServletRequest requestData) { |
|
|
|
|
|
|
|
//dataModel.addAttribute("book", new Book()); |
|
|
|
|
|
|
|
httpServerLogger.logMessageNormal( |
|
|
|
requestData, |
|
|
|
"HTTPOK" |
|
|
|
); |
|
|
|
|
|
|
|
return landingPageURL; |
|
|
|
dataModel.addAttribute("books", bookRepository.findAll()); |
|
|
|
|
|
|
|
return bookListPageURL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Redirect |
|
|
|
@RequestMapping( |
|
|
|
value = "/", |
|
|
|
value = { "/", landingPageURL }, |
|
|
|
method = RequestMethod.GET |
|
|
|
) |
|
|
|
@ResponseStatus(HttpStatus.FOUND) |
|
|
|
public String redirectToDefaultWebForm() { |
|
|
|
return "redirect:" + landingPageURL; |
|
|
|
return "redirect:" + bookListPageURL; |
|
|
|
} |
|
|
|
|
|
|
|
// Other URL requests |
|
|
|