package com.test.bean;
import java.util.Date;
public class User
{
private String username;
private String password;
private String repassword;
private int age;
private Date birthday;
private Date graduation;
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getRepassword()
{
return repassword;
}
public void setRepassword(String repassword)
{
this.repassword = repassword;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public Date getBirthday()
{
return birthday;
}
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
public Date getGraduation()
{
return graduation;
}
public void setGraduation(Date graduation)
{
this.graduation = graduation;
}
}
package com.test.bean;
public class Point
{
private int x;
private int y;
public int getX()
{
return x;
}
public void setX(int x)
{
this.x = x;
}
public int getY()
{
return y;
}
public void setY(int y)
{
this.y = y;
}
@Override
public String toString()
{
return "x = " + x + " y = " + y;
}
}
package com.test.exception;
public class PasswordException extends Exception
{
private String message;
public PasswordException(String message)
{
super(message);
this.message = message;
}
public String getMessage()
{
return message;
}
public void setMessage(String message)
{
this.message = message;
}
}
package com.test.exception;
public class UsernameException extends Exception
{
private String message;
public UsernameException(String message)
{
super(message);
this.message = message;
}
public String getMessage()
{
return message;
}
public void setMessage(String message)
{
this.message = message;
}
}
package com.test.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class MyInterceptor implements Interceptor
{
private String hello;
public String getHello()
{
return hello;
}
public void setHello(String hello)
{
this.hello = hello;
}
public void destroy()
{
System.out.println("destroy");
}
public void init()
{
System.out.println("init");
System.out.println(hello);
}
public String intercept(ActionInvocation invocation) throws Exception
{
System.out.println("intercept");
String result = invocation.invoke();
System.out.println("finish");
return result;
}
}
package com.test.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class MyInterceptor2 extends AbstractInterceptor
{
@Override
public String intercept(ActionInvocation invocation) throws Exception
{
System.out.println("intercept2");
String result = invocation.invoke();
System.out.println("finish2");
return result;
}
}
package com.test.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.test.listener.MyListener;
public class MyInterceptor3 extends MethodFilterInterceptor
{
@Override
public void init()
{
System.out.println("init3");
}
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception
{
invocation.addPreResultListener(new MyListener());
System.out.println("my interceptor3");
String result = invocation.invoke();
System.out.println("after my interceptor3 finished");
return result;
}
}
package com.test.interceptor;
import java.util.Map;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class AuthInterceptor extends AbstractInterceptor
{
@Override
@SuppressWarnings("unchecked")
public String intercept(ActionInvocation invocation) throws Exception
{
Map map = invocation.getInvocationContext().getSession();
if(map.get("user") == null)
{
return Action.LOGIN;
}
else
{
return invocation.invoke();
}
}
}