2017-07-03 28 views
0

我必須刪除jstl庫(許可證問題)。使用jsp scriptlet重寫<c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>的正確方法是什麼?

我想在幾個其他下面的代碼:

<%= session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION.message") %> 

但它返回null。

此外,我不能簡單地更改爲${SPRING_SECURITY_LAST_EXCEPTION.message},因爲所有特殊的html字符都需要轉義。

回答

0

SPRING_SECURITY_LAST_EXCEPTION是其中一個彈簧異常已經存儲,因此必須訪問它作爲以下內容的會話屬性:

<%= session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION").getMessage() %> 

SPRING_SECURITY_LAST_EXCEPTION表示異常和消息是它的一個屬性。

編輯:

<%= ((AuthenticationCredentialsNotFoundException)session.getAttr‌​ibute("SPRING_SECURI‌​TY_LAST_EXCEPTION"))‌​.getMessage() %>工作。當然,我不得不導入AuthenticationCredentialsNotFoundException

+0

我試過了,但我得到了「方法getMessage()未定義類型對象」錯誤。我嘗試將它轉換爲字符串,但我收到了類似的錯誤消息 – gali4ka

+0

<%=((AuthenticationCredentialsNotFoundException)session.getAttribute(「SPRING_SECURITY_LAST_EXCEPTION」))。getMessage()%>工作。當然,我不得不導入AuthenticationCredentialsNotFoundException – gali4ka

相關問題