67,550
社区成员




@Aspect
@Component
public class ActionInterceptor {
/**
* 声明切入点
*/
@Pointcut("execution(String com.uestc.babasport.action..*.*(..))")
public void anyMethod() {
}
@Around("anyMethod()")
public Object around(ProceedingJoinPoint joinPoint){
Object object = null;
try {
System.out.println("环绕通知(前)"+joinPoint.getSignature().getName());
object = joinPoint.proceed();
System.out.println(object.toString());
//System.out.println("环绕通知(后)");
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return object;
}
}
@Controller
public class EmployeeLoginAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private String userName;
private String password;
private String tip;
@Resource
private EmployeeService employeeService;
//seter getter省略了
@Override
public String execute() throws Exception {
System.out.println(getUserName()+"--"+getPassword());
if (getUserName() != null && !"".equals(getUserName().trim())
&& getPassword() != null && !"".equals(getPassword().trim())) {
if(employeeService.validate(getUserName(), getPassword())){
ActionContext ac = ActionContext.getContext();
ac.put("message", "您已经成功登录");
ac.put("url", "default");
ac.getSession().put("employee", employeeService.find(Employee.class,getUserName().trim()));
setTip(null);
setUserName(null);
setPassword(null);
return "message";
}else{
tip = "您输入的用户名或者密码有误";
}
}
return "failer";
}
}