commit
0105456ae2
@ -16,14 +16,14 @@ public class Config implements WebMvcConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
registry.addViewController("/").setViewName("index");
|
registry.addViewController("/")
|
||||||
|
.setViewName("index");
|
||||||
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ITemplateResolver templateResolver() {
|
public ITemplateResolver templateResolver() {
|
||||||
ClassLoaderTemplateResolver resolver
|
ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
|
||||||
= new ClassLoaderTemplateResolver();
|
|
||||||
resolver.setPrefix("templates/books/");
|
resolver.setPrefix("templates/books/");
|
||||||
resolver.setSuffix(".html");
|
resolver.setSuffix(".html");
|
||||||
resolver.setTemplateMode(TemplateMode.HTML);
|
resolver.setTemplateMode(TemplateMode.HTML);
|
||||||
|
@ -16,7 +16,7 @@ public class InMemoryBookService implements BookService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Book> findAll() {
|
public List<Book> findAll() {
|
||||||
return new ArrayList(booksDB.values());
|
return new ArrayList<>(booksDB.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,14 +29,14 @@ public class InMemoryBookService implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<Long, Book> bookMap = books.stream()
|
Map<Long, Book> bookMap = books.stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(Book::getId, Function.identity()));
|
||||||
Book::getId, Function.identity()));
|
|
||||||
|
|
||||||
booksDB.putAll(bookMap);
|
booksDB.putAll(bookMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getNextId(){
|
private Long getNextId() {
|
||||||
return booksDB.keySet().stream()
|
return booksDB.keySet()
|
||||||
|
.stream()
|
||||||
.mapToLong(value -> value)
|
.mapToLong(value -> value)
|
||||||
.max()
|
.max()
|
||||||
.orElse(0) + 1;
|
.orElse(0) + 1;
|
||||||
|
@ -5,9 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||||
|
|
||||||
@SpringBootApplication(
|
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class, DataSourceAutoConfiguration.class })
|
||||||
exclude = {SecurityAutoConfiguration.class,
|
|
||||||
DataSourceAutoConfiguration.class})
|
|
||||||
public class ListBindingApplication {
|
public class ListBindingApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -41,7 +41,9 @@ public class MultipleBooksController {
|
|||||||
@GetMapping(value = "/edit")
|
@GetMapping(value = "/edit")
|
||||||
public String showEditForm(Model model) {
|
public String showEditForm(Model model) {
|
||||||
List<Book> books = new ArrayList<>();
|
List<Book> books = new ArrayList<>();
|
||||||
bookService.findAll().iterator().forEachRemaining(books::add);
|
bookService.findAll()
|
||||||
|
.iterator()
|
||||||
|
.forEachRemaining(books::add);
|
||||||
|
|
||||||
model.addAttribute("form", new BooksCreationDto(books));
|
model.addAttribute("form", new BooksCreationDto(books));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user