How we can handle the unknown url call in the java webservices class?

0 votes
92 views
asked May 3 by admin (8,115 points)
Hi  All

  If i received unknown service end point have to return the 404 error . Can you please give sample code?

1 Answer

0 votes
answered May 3 by mark

Hi

  RequestMapping fallback method: We can create a fallback method for the controller class to make sure we are catching all the client requests even though there are no matching handler methods. It is useful in sending custom 404 response pages to users when there are no handler methods for the request.

@RequestMapping("*")
@ResponseBody
public String fallbackMethod(){
	return "fallback method";
}
...