Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda