Reputation: 13986
I'm using an interceptor to restrict access to certain users in the app. For instance:
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
Logger.logRequest(request);
return list.contains(user);
}
If the list contains the user, it completes the request. Otherwise, it does nothing.
How do I display a custom page if the user doesn't have access? Right now, if it's false, it just shows a blank page which is not great for user experience.
Upvotes: 3
Views: 9198
Reputation: 13986
It looks like you can do a response redirect without hitting the servlet. The following works:
if (list.contains(user))
return true;
else
{
//set up the view
response.sendRedirect("nope_view");
return false;
}
Upvotes: 8