Return JSON on unauthorized REST service request using Spring Security 'hasPermission()'
问题 I am implementing method level restriction/authorization (on REST services ) using Spring security. I have used the spring expression language and implemented custom Expression Evaluator. It is working fine for me. However, if an unauthorized user tries to access the service, it is responding with a login page. Since my application is REST based only , I want to return only JSON data for all the requests. How do I make it return JSON instead of the login page?(eg: {status : Denied} ) Here is