I use @ExceptionHandler to handle exceptions thrown by my web app, in my case my app returns JSON response with HTTP status for error
@ExceptionHandler
JSON
HTTP status
You can use servlet standard way to handle 404 error. Add following code in web.xml
web.xml
404 /404error.html