zoukankan      html  css  js  c++  java
  • struts2表单数据无法自动注入

    场景:

         在实现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     }
  • 相关阅读:
    每日一题_191208
    每日一题_191207
    每日一题_191206
    每日一题_191205
    每日一题_191204
    每日一题_191203
    每日一题_191202
    每日一题_191201
    每日一题_191130
    2020届成都一诊理科16题
  • 原文地址:https://www.cnblogs.com/alcc/p/3649950.html
Copyright © 2011-2022 走看看