I am building a Spring Boot and Thymeleaf application with the custom context path:
server.servlet.context-path=/myapp
So the application can be accessed as:
http://localhost:8080/myapp
All content is served on the /myapp
context path, except for one mapping for a special case which needs to be:
http://localhost:8080/exception
Is there a way to make an exception to the custom context path for this special case?
CodePudding user response:
No, Context-path is globally for the whole application, but still, there are two ways to archive what you want-
- You can put your Context-path to all the controllers across the application manually, that way you can exclude your exception end-point from Context-path.
- You can create a second Dispatcher-Servlet this way you can host your other end-point on a different port.
I personally won't prefer any of the above solutions as the first one is not suitable for a large application and the second solution adds extra complexity.