问题是:
hasPermission返回带有“访问被拒绝”消息的html页面
是否可以将定制的消息返回给客户端 消息-> {statusCode,消息,actionName}
@Url.GetCropUrl(Model.Content, "yourImagePropertyName", "fac")
答案 0 :(得分:0)
尝试通过
解决此问题 @Component
@ControllerAdvice
public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint{
...
@ExceptionHandler(value = { MyAccessDeniedException.class })
public void commence(HttpServletRequest request, HttpServletResponse response, MyAccessDeniedException ex ) throws IOException {
String json = new ObjectMapper().writeValueAsString(ex.getRequestModel());
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
response.getWriter().write(json);
response.flushBuffer();
}