场景:

     在实现struts2的注解方式的拦截器后,发现前台form submit到后台的数据无法被action中的类接收。

 

原因:

  action默认的拦截器是defaultStack,当我们实现自己拦截器后会覆盖原来的拦截器。

 

解决:

  加上默认的拦截器

 1 @Action(value = "/loginin", results = {
 2             @Result(name = SUCCESS, location = "public/home.jsp", type = "dispatcher"),
 3             @Result(name = "login", location = "public/login.jsp", type = "dispatcher"),
 4             @Result(name = "loginError", location = "public/loginError.jsp", type = "dispatcher") }, interceptorRefs = {
 5             @InterceptorRef("timer"),@InterceptorRef("auth"),@InterceptorRef("defaultStack") })
 6     public String loginin() {
 7         logger.info(JSON.toJSON(user));
 8         boolean status = userService.logininVerify(user);
 9         if (status == true) {
10             session.put("ROLE", role);
11             return SUCCESS;
12         } else {
13             return "loginError";
14         }
15     }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-01-24
  • 2021-11-06
猜你喜欢
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2021-05-08
  • 2021-05-28
  • 2022-12-23
相关资源
相似解决方案