diff --git a/src/main/java/org/springframework/samples/petclinic/rest/RootRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/RootRestController.java index 29f545705..b903227fc 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/RootRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/RootRestController.java @@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -34,9 +35,12 @@ @RequestMapping("/") public class RootRestController { + @Value("#{servletContext.contextPath}") + private String servletContextPath; + @RequestMapping(value = "/") public void redirectToSwagger(HttpServletResponse response) throws IOException { - response.sendRedirect("/petclinic/swagger-ui.html"); + response.sendRedirect(this.servletContextPath + "/swagger-ui.html"); } }