2017-07-03 26 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

相关问题