簡體   English   中英

基於表單的身份驗證將變量傳遞給JSP

[英]Form Based authetication passing variable to JSP

We are using a form based authentication and below is the snippet from web.xml 

 <login-config>
  <auth-method> FORM </auth-method>
  <form-login-config>
        <form-login-page>/login.jsp?fromIndex=true</form-login-page>
        <form-error-page>/login.jsp?fromIndex=true&ldapAuth=fail</form-error-page>
    </form-login-config>
 </login-config>

而且我確實有一個登錄過濾器來處理身份驗證。 因此,如果身份驗證失敗,我也想向jsp發送錯誤代碼以顯示錯誤消息。 由於認證失敗時HttpRequest不會傳遞到JSP頁面,因此我無法通過放置http request來發送變量。

有沒有另一種方法可以將變量傳遞給登錄錯誤的jsp頁面?

而是通過參數,應通過屬性將數據放入HttpRequest

// In the filter:
request.setAttribute("name", new MyObject());

// In the JSP:
MyObject obj=(MyObject)request.getAttribute("name");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM