@SuppressWarnings("serial")
public class MyInterceptor extends AbstractInterceptor { @SuppressWarnings("unchecked")
@Override
public String intercept(ActionInvocation arg0) throws Exception {
// HttpSession hs = ServletActionContext.getRequest().getSession();
// String username = (String) hs.getAttribute("username");
//
ActionContext ac = arg0.getInvocationContext();
Map session = ac.getSession();
System.out.println(session.size());
Userinfo userinfo = (Userinfo) session.get("user");
if(userinfo==null){
return Action.LOGIN;
}else{
return arg0.invoke();
}
}}
接受的前台数据总是为null 怎么办啊 有谁能帮忙啊
public class MyInterceptor extends AbstractInterceptor { @SuppressWarnings("unchecked")
@Override
public String intercept(ActionInvocation arg0) throws Exception {
// HttpSession hs = ServletActionContext.getRequest().getSession();
// String username = (String) hs.getAttribute("username");
//
ActionContext ac = arg0.getInvocationContext();
Map session = ac.getSession();
System.out.println(session.size());
Userinfo userinfo = (Userinfo) session.get("user");
if(userinfo==null){
return Action.LOGIN;
}else{
return arg0.invoke();
}
}}
接受的前台数据总是为null 怎么办啊 有谁能帮忙啊
这里不使用拦截器,直接进action,楼主试试,应该也一样取不取session中的user。
<interceptor name="myInterceptor" class="cn.com.MyInterceptor"/>
<interceptor-stack name="myInterceptorStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="myInterceptor"/>
</interceptor-stack>
</interceptors>
<action name="list_*" class="cn.com.action.TheAction" method="{1}"> <!--拦截的TheAction中的方法-->
<interceptor-ref name="myInterceptorStack" />
</action>