But what you're describing could be done for php, or any other backend language/framework... There's nothing unique to Astro in this regard.
Do you know how you can do this in spring? Let's say I used Thymeleaf, is there a maven target I can use to walk over a database and generate every iteration of a html website?