Reflect grouping in directory structure

This commit is contained in:
Andy Wilkinson
2022-10-28 14:36:50 +01:00
parent 393e1cb6bf
commit 7112a4b6a4
788 changed files with 9 additions and 100 deletions

View File

@@ -0,0 +1,37 @@
package com.example.thymeleaf.webmvc;
import java.util.List;
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE)
public class TestController {
@GetMapping("/greeting")
@RegisterReflectionForBinding(IndexModel.class)
public String index(@RequestParam(defaultValue = "world") String name, Model model) {
model.addAttribute("model", new IndexModel("Hello", name));
return "index";
}
@GetMapping("/authors")
@RegisterReflectionForBinding(Author.class)
public String authors(Model model) {
model.addAttribute("authors", List.of(new Author("Brian Goetz"), new Author("Joshua Bloch")));
return "authors";
}
public record IndexModel(String greeting, String name) {
}
public record Author(String name) {
}
}

View File

@@ -0,0 +1,14 @@
package com.example.thymeleaf.webmvc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ThymeleafWebMvcApplication {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(ThymeleafWebMvcApplication.class, args);
Thread.currentThread().join(); // To be able to measure memory consumption
}
}