Imagine you need to make a simple web application with Spring Boot that serves a static homepage and a dynamic page displaying current server time. Discuss the project structure you would use.

A simple Spring Boot web app serving a static homepage and a dynamic time page follows the standard Maven project layout, separating static assets, dynamic templates, code, and configuration into their conventional directories.

Key Points: • The main application class and a @Controller live under src/main/java. • The controller maps / to serve the homepage and /time to render a dynamic page showing the current server time. • Static files like index.html, CSS, and JS go under src/main/resources/static and are served directly. • Dynamic content uses a templating engine like Thymeleaf, with templates under src/main/resources/templates. • Configuration (server port, logging, etc.) lives in src/main/resources/application.properties.

Example: Visiting / returns the static index.html directly, while visiting /time hits TimeController, which passes LocalDateTime.now() into a Thymeleaf template that renders it inside the HTML.

Code Example:

@Controller
public class TimeController {

    @GetMapping("/time")
    public String time(Model model) {
        model.addAttribute("now", LocalDateTime.now());
        return "time";
    }
}

Interview Tip: A concise interview answer is:

"I'd follow standard Spring Boot conventions -- static/ for the homepage assets, templates/ with Thymeleaf for the dynamic time page, a controller mapping both routes, and application.properties for configuration. That keeps static and dynamic content clearly separated and easy to extend later."