-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup Spring Loaded, and add BookController
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
MAVEN_OPTS="-javaagent:springloaded-1.2.1.RELEASE.jar -noverify" mvn spring-boot:run |
Binary file not shown.
58 changes: 58 additions & 0 deletions
58
src/main/java/spring_boot_tutorial/controller/BookController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package spring_boot_tutorial.controller; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
@Controller | ||
@RequestMapping("/books") | ||
public class BookController { | ||
|
||
@RequestMapping(method = RequestMethod.GET) | ||
public String index(Model model) { | ||
List<String> books = Arrays.asList("foo", "bar", "foobar"); | ||
model.addAttribute("books", books); | ||
return "book-index"; | ||
} | ||
|
||
@RequestMapping(value = "/{id}", method = RequestMethod.GET) | ||
public String show() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
@RequestMapping(value = "/new", method = RequestMethod.GET) | ||
public String new_() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.POST) | ||
public String create() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
@RequestMapping(value = "/edit", method = RequestMethod.GET) | ||
public String edit() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.PUT) | ||
public String update() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
@RequestMapping(method = RequestMethod.DELETE) | ||
public String destroy() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<title></title> | ||
<meta name="description" content="" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<style> | ||
table {border: 1px solid #ccc; border-collapse: collapse} | ||
th, td {border: 1px solid #ccc; padding: 8px;} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<h1>All books</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>Title</th> | ||
<th>Author</th> | ||
<th>Publisher</th> | ||
</tr> | ||
</thead> | ||
<tbody th:remove="all-but-first"> | ||
<tr th:each="book, itr : ${books}"> | ||
<td th:text="${itr.index} + 1">1</td> | ||
<td th:text="${book}">book1</td> | ||
<td th:text="TODO">author1</td> | ||
<td th:text="TODO">publisher1</td> | ||
</tr> | ||
<tr> | ||
<td>2</td> | ||
<td>book2</td> | ||
<td>author2</td> | ||
<td>publisher2</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
</body> | ||
</html> |