0
我在春季安全中編寫了自定義過濾器,但過濾器沒有被調用。我通過在過濾器類中添加日誌語句來確保這一點。不知道在哪裏錯過或錯了。請看下面的代碼:春季安全過濾器沒有被調用
popUpClassFilter.java
public class popUpClassFilter implements AuthenticationSuccessHandler {
private static final Logger log = LoggerFactory.getLogger(popUpClass.class);
@Override
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
//do some logic here if you want something to be done whenever
//the user successfully logs in.
log.debug("Entered into customfilter");
HttpSession session = httpServletRequest.getSession();
User user = SecurityClass.getUserDetails();
session.setAttribute("id", user.ID());
session.setAttribute("state", user.State());
//set our response to OK status
httpServletResponse.setStatus(HttpServletResponse.SC_OK);
//since we have created our custom success handler, its up to us to where
//we will redirect the user after successfully login
httpServletResponse.sendRedirect("home");
}
}
的Config.xml
<bean id="popUpClass" class="myPackage.security.popUpClassFilter" />
<security:http entry-point-ref="myAppAuthEntryPoint" use-expressions="true">
.............
<security:custom-filter after="LOGIN_FILTER" ref="popUpFilter"/>
</security:http>
在此先感謝。
@Adriaan喜。當然,從下次我會對同一篇文章進行編輯。我是堆棧溢出新手。 – user7637864