繁体   English   中英

如何在spring security oauth2中将错误/异常作为json对象返回?

[英]How to return error/exception as json object in spring security oauth2?

我正在服务器服务器spring restfull web-services并在spring-security.xml中编写了所有配置( 我的oauth2 jar版本是2.0.10 RELEASE ),那么现在如何在浏览器上呈现自定义jsp来显示此错误?

创建令牌时Json响应

 {
    "access_token": "d7a82d67-228f-459f-bf02-5c3501706c6d",
    "token_type": "bearer",
    "expires_in": 29,
    "scope": "read trust write"
 }

XML格式错误

<oauth>
    <error_description> An Authentication object was not found in the SecurityContext </error_description>
    <error>unauthorized</error>
</oauth>

我只是想删除这个xml响应,并希望我的自定义error.jsp

web.xml中添加它

 <!-- Unauthorized -->
   <error-page>
    <error-code>401</error-code>
    <location>x.jsp</location>
  </error-page>

 <!-- access forbidden -->
  <error-page>
    <error-code>403</error-code>
    <location> x.jsp</location>
  </error-page>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM