Requesting page on button click with Spring, Thymeleaf and js

so I’ve done simple implementatnion on reload-less content loading.
It uses AJAX to load content from another controller.

    $(document.body).on('click', 'button#first', function() {
        $('#content').load("/first");
    });

    $(document.body).on('click', 'button#second',function() {
        $('#content').load("/second");
    });

For now I have 3 controllers:

  • HomeController (localhost/)
  • FirstController (localhost/first)
  • SecondController (localhost/second)
    @GetMapping("/first")
    public String getFirst() {
        return "includes/first:: content";
    }

    @GetMapping("/second")
    public String getSecond() {
        return "includes/second :: content";
    }

And that works fine, but of course I can also just enter /first or /second and get unproper content as they’re fragments. So my question is there any way to prevent people from just entering /first in their browser or handle loading content server-side instead of ajax?