![](/img/trans.png)
[英]Extending spring security UsernamePasswordAuthenticationFilter
[英]When overriding the method of UsernamePasswordAuthenticationFilter class eclipse shows error in spring-security
我想在我的 Spring-MVC 中为登录和注销页面设置不同角色的不同用户名。
我从下面的链接中学习过,我使用的是 spring 4.2.5:
http://www.raistudies.com/spring-security-tutorial/role-based-spring-jsp-taglibs/
但是我的一个班级显示错误:
public class AjaxAuthenticationProcessingFilter extends
UsernamePasswordAuthenticationFilter {
@Override
protected void successfulAuthentication(HttpServletRequest request,
HttpServletResponse response, Authentication authResult)
throws IOException, ServletException {
super.successfulAuthentication(request, response, authResult);
}
}
Eclipse 在方法上显示编译时错误,
AjaxAuthenticationProcessingFilter 类型的方法 successAuthentication(HttpServletRequest, HttpServletResponse, Authentication) 必须覆盖或实现超类型方法
和其他错误是,当我打电话successfulAuthentication
超类的方法super.successfulAuthentication(request, response, authResult);
.
您可以看到下面给出的错误:
AbstractAuthenticationProcessingFilter 类型中的方法 successAuthentication(HttpServletRequest, HttpServletResponse, FilterChain, Authentication) 不适用于参数 (HttpServletRequest, HttpServletResponse, Authentication)
如果有人知道 spring 安全性以实现具有不同角色的不同用户的任何链接,请在 spring-xml 配置的帮助下告诉我。
试试下面的代码..检查你的进口。
并且主要
successfulAuthentication(HttpServletRequest request,
HttpServletResponse response,Authentication authResult)
已弃用。
使用
successfulAuthentication(HttpServletRequest request,
HttpServletResponse response,FilterChain a, Authentication authResult)
最后,
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
public class AjaxAuthenticationProcessingFilter extends
UsernamePasswordAuthenticationFilter {
@Override
protected void successfulAuthentication(HttpServletRequest request,
HttpServletResponse response,FilterChain filter, Authentication authResult)
throws IOException, ServletException {
super.successfulAuthentication(request, response,filter, authResult);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.