易做图只运行一次
package interceptot;import java.util.Iterator;
import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class MyInterceptot extends AbstractInterceptor {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public String intercept(ActionInvocation invocation) throws Exception {
System.out.println("易做图");
ActionContext ctx = invocation.getInvocationContext();
String object=ctx.toString();
Map session = ctx.getSession();
System.out.print("session");
print(session);
Object cAction = ctx.getActionInvocation().getAction();
Map uApplication = ctx.getApplication();
System.out.print("uApplication:");
print(uApplication);
Map uParameters = ctx.getParameters();
System.out.print("uParameters:");
print(uParameters);
Map uContextMap = ctx.getContextMap();
System.out.print("uContextMap:");
print(uContextMap);
String bean=ctx.getName();
System.out.println(bean);
if(bean.equals("login")||bean.equals("registrat")||session.get("user")!=null){
System.out.println("易做图通过");
return invocation.invoke();
}
System.out.println("易做图没通过");
return "login";
}
public void print(Map map) {
Iterator it=map.keySet().iterator();
if (it.hasNext()) {
System.out.println(it.next());
}
}
}
结果:
uParameters:user.username
uContextMap:com.opensymphony.xwork2.ActionContext.parameters
login
易做图通过
bean+ 密码
Hibernate: select user0_.id as id0_, user0_.`username` as username2_0_, user0_.`password` as password3_0_ from user user0_ where user0_.`username`=?
[] --------------------编程问答-------------------- 没看懂。 条件满足不是都有输出吗? --------------------编程问答-------------------- 易做图通过只输出了一次 --------------------编程问答-------------------- 而且易做图不拦易做图问其他网页的请求
补充:Java , Java EE