I am creating a webservice rest, and it is working properly, but there is a situation that I could not handle: if the url provided is searching for a non-existent method, the requester is redirected to the error screen of my system, I would like to display a custom message. Following description:
url1 (valid): link
url (invalid): link
I would like to receive a url other than url1, the system would display a custom message instead of redirecting it to the page not found. But how do I create a method to intercept and validate the url, where the path entered does not exist in my class?
@Path("/ws/exemplo")
public class exemploResource {
//único método implementado atualmente
@GET()
@Produces("text/plain")
@Path("consulta1")
public String consulta1(@QueryParam("param1") final String param1,
@QueryParam("param2") final String param2,
final @Context HttpServletRequest request) {
...
}