package com.lh.MyInterceptor;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.ServletActionContext;import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;public class MyInterceptor implements Interceptor {
public void destroy() {
// TODO Auto-generated method stub
} public void init() {
// TODO Auto-generated method stub
} public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest req = ServletActionContext.getRequest();
System.out.println(req.getParameter("username"));
System.out.println(req.getSession().getAttribute("username"));
if (req.getParameter("username") == null) {
return Action.LOGIN;
} else {
return invocation.invoke();
} }
}
(菜鸟求教)
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;public class MyInterceptor implements Interceptor {
public void destroy() {
// TODO Auto-generated method stub
} public void init() {
// TODO Auto-generated method stub
} public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest req = ServletActionContext.getRequest();
System.out.println(req.getParameter("username"));
System.out.println(req.getSession().getAttribute("username"));
if (req.getParameter("username") == null) {
return Action.LOGIN;
} else {
return invocation.invoke();
} }
}
(菜鸟求教)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货