簡體   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