0

我正在做一个项目,我必须在其中包含一些来自JSP的代码。该 JSP 的代码如下(与Spring Security相关)...

<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core_rt' %>
<%@ page import="org.springframework.security.ui.AbstractProcessingFilter" %>
<%@ page import="org.springframework.security.ui.webapp.AuthenticationProcessingFilter" %>
<%@ page import="org.springframework.security.AuthenticationException" %>
....
<c:if test="${not empty param.login_error}">
      <font color="red">
        Your login attempt was not successful, try again.<br/><br/>
        Reason: <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>.
      </font>
</c:if>
....
<c:if test="${not empty param.login_error}"><c:out value="${SPRING_SECURITY_LAST_USERNAME}"/></c:if>
...

这是我试图在我的 servlet 中检查的内容:

enumr = request.getAttributeNames();
while(enumr.hasMoreElements())
{
    String element = enumr.nextElement()+"";
    out.print("<h3>Read an element:");
    out.print(element+" » ");
    out.print(request.getAttribute(element));
    out.print("</h3>");
}

和相应的输出:

Read an element:__spring_security_session_fixation_filter_applied » true
Read an element:__spring_security_filterSecurityInterceptor_filterApplied » true
Read an element:hibernateFilter.FILTERED » true
Read an element:__spring_security_session_integration_filter_applied » true
Read an element:requestContextFilter.FILTERED » true

有根据的猜测是,我可以在阅读时得出错误结论, _spring_security_filterSecurityInterceptor_filterApplied描述了发生了错误。


如何阅读错误消息?

4

2 回答 2

1

首先:您没有使用 Facelets。您正在使用 JSP。这两种技术都是来自 Sun 的独立视图技术,其中 Facelets 或多或少被视为增强型 JSP。所以这个主题被错误地标记为 Facelets。

其次:自 1998 年的 HTML 4.01 以来,HTML <font> 标记已被弃用。您应该使用 CSS。

回到你的问题:我不做Spring,所以我不能深入细节,但是你检查过会话范围的属性吗?快速谷歌搜索键“SPRING_SECURITY_LAST_EXCEPTION.message”得知它存储在会话范围内。

于 2009-11-02T11:12:57.187 回答
0

有用:

String keyToSearch = AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY;
Object value = request.getSession().getAttribute(keyToSearch);

再次感谢 BalusC

于 2009-11-02T12:07:37.410 回答