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