Bird
0
0

Given this Spring Boot project structure, what will happen if you place a static HTML file inside src/main/resources/static/index.html and run the application?

medium📝 component behavior Q4 of 15
Spring Boot - Fundamentals
Given this Spring Boot project structure, what will happen if you place a static HTML file inside src/main/resources/static/index.html and run the application?
AThe application will fail to start due to invalid file placement
BThe HTML file will not be accessible because resources folder is for Java classes only
CThe HTML file will be served automatically at http://localhost:8080/index.html
DThe HTML file will be served only if explicitly mapped in a controller
Step-by-Step Solution
Solution:
  1. Step 1: Understand static resource handling in Spring Boot

    Spring Boot serves static content from src/main/resources/static automatically.
  2. Step 2: Confirm URL mapping for static files

    Files in static folder are accessible by their filename at root URL path.
  3. Final Answer:

    The HTML file will be served automatically at http://localhost:8080/index.html -> Option C
  4. Quick Check:

    Static files in resources/static = auto-served [OK]
Quick Trick: Put static files in resources/static for automatic serving [OK]
Common Mistakes:
  • Thinking resources folder is only for Java classes
  • Expecting manual controller mapping for static files
  • Assuming app fails on static files in resources

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes