Struts2 如何从doFilter方法调用struts操作

Struts2 如何从doFilter方法调用struts操作,struts2,filter,web.xml,requestdispatcher,struts-action,Struts2,Filter,Web.xml,Requestdispatcher,Struts Action,我的struts.xml有两个操作,如下所示 主页 /Profile/add/Failure.jsp /Profile/add/EmailAuthentication.jsp /Profile/add/ProfileDetails.jsp /index.jsp 我需要从doFilter方法调用一个操作(dologincheck)。我被困在这里,因为我不知道如何从doFilter方法调用操作 public void doFilter(ServletRequest-req、ServletResp

我的
struts.xml
有两个操作,如下所示


主页
/Profile/add/Failure.jsp
/Profile/add/EmailAuthentication.jsp
/Profile/add/ProfileDetails.jsp
/index.jsp
我需要从
doFilter
方法调用一个操作(
dologincheck
)。我被困在这里,因为我不知道如何从
doFilter
方法调用操作

public void doFilter(ServletRequest-req、ServletResponse-res、FilterChain-chain)抛出
IOException,ServletException{
试一试{
println(“这是jsp页面之前的do过滤器”);
HttpServletRequest请求=(HttpServletRequest)请求;
HttpServletResponse=((HttpServletResponse)res);
HttpSession session=request.getSession(true);
字符串用户名、密码;
饼干[]饼干;
LoginPojo user=(LoginPojo)session.getAttribute(“用户名”);
if(user==null){
cookies=request.getCookies();
如果(cookies!=null&&cookies.length>0){
用户名=getCookieValue(cookies,用户名);
密码=getCookieValue(cookies,密码);
System.out.println(用户名);
System.out.println(密码);
如果(用户名!=null和密码!=null){
LoginPojo pojo=新的LoginPojo(用户名、密码);
结果=dao.Login(pojo);
session.setAttribute(“用户名”,用户);//用户会话?
request.getRequestDispatcher(“dologincheck”).forward(请求,
反应);
}否则{
request.getRequestDispatcher(“/index.jsp”).forward(请求,
反应);
}
}否则{
request.getRequestDispatcher(“/index.jsp”).forward(请求,
反应);
}
}
}捕获(例外e){
}
链式过滤器(要求、恢复);
//抛出新的UnsupportedOperationException(“尚未支持”);
}
web.xml
的过滤部分是


支柱2
org.apache.struts2.dispatcher.ng.filter.strutspreadexecutefilter
支柱2
/*
自动克隆素
com.platinum.uac.biz.AutomaticLogin
自动克隆素
*.jsp
*.行动
行动
要求

在网上搜索后,我得到了答案

使用

response.sendRedirect(“dologincheck”);
而不是

request.getRequestDispatcher(“dologincheck”).forward(请求,响应);

绕过操作执行,直到struts2筛选器链接,然后使用拦截器重定向到实际操作。而不是使用拦截器来实现相同的操作。