• <tfoot id='SmD5X'></tfoot>

  • <legend id='SmD5X'><style id='SmD5X'><dir id='SmD5X'><q id='SmD5X'></q></dir></style></legend>

    • <bdo id='SmD5X'></bdo><ul id='SmD5X'></ul>
        <i id='SmD5X'><tr id='SmD5X'><dt id='SmD5X'><q id='SmD5X'><span id='SmD5X'><b id='SmD5X'><form id='SmD5X'><ins id='SmD5X'></ins><ul id='SmD5X'></ul><sub id='SmD5X'></sub></form><legend id='SmD5X'></legend><bdo id='SmD5X'><pre id='SmD5X'><center id='SmD5X'></center></pre></bdo></b><th id='SmD5X'></th></span></q></dt></tr></i><div id='SmD5X'><tfoot id='SmD5X'></tfoot><dl id='SmD5X'><fieldset id='SmD5X'></fieldset></dl></div>
      1. <small id='SmD5X'></small><noframes id='SmD5X'>

        Struts 2.0 中登录时使用的拦截器

        Interceptors use in login in Struts 2.0(Struts 2.0 中登录时使用的拦截器)

        1. <legend id='oYzIo'><style id='oYzIo'><dir id='oYzIo'><q id='oYzIo'></q></dir></style></legend>

            <small id='oYzIo'></small><noframes id='oYzIo'>

              <tbody id='oYzIo'></tbody>
          1. <tfoot id='oYzIo'></tfoot>

                <bdo id='oYzIo'></bdo><ul id='oYzIo'></ul>

                  <i id='oYzIo'><tr id='oYzIo'><dt id='oYzIo'><q id='oYzIo'><span id='oYzIo'><b id='oYzIo'><form id='oYzIo'><ins id='oYzIo'></ins><ul id='oYzIo'></ul><sub id='oYzIo'></sub></form><legend id='oYzIo'></legend><bdo id='oYzIo'><pre id='oYzIo'><center id='oYzIo'></center></pre></bdo></b><th id='oYzIo'></th></span></q></dt></tr></i><div id='oYzIo'><tfoot id='oYzIo'></tfoot><dl id='oYzIo'><fieldset id='oYzIo'></fieldset></dl></div>
                  本文介绍了Struts 2.0 中登录时使用的拦截器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在设计一个基本应用程序,其中用户提供他的用户 ID 和密码,如果登录成功,他将被重定向到主页.现在进行验证,如果用户 ID 和密码不为空,我想使用拦截器.但我无法找出如何访问拦截器中请求参数的值.JSP代码

                  I am designing a basic application in which User provides his user id and password and if the login is successful he is redirected to home page. Now for the validation I want to use interceptors if the user id and password are not empty. But I am not able to find out how I can access the values of request parameters in Interceptors. JSP Code

                  <s:form action="Login.action" method="post">
                         <s:textfield label="Username" name="bean.userId"/>
                         <s:submit value="Login" />
                  </s:form>
                  

                  型号

                  @Entity
                  @Table(name="login")
                  public class Login implements Serializable
                  {
                  public Login()
                  {
                  }
                  public Login(String userId1, String userPassword1) {
                      userId1 = userId;
                      userPassword1 = userPassword;
                  }
                  private String userId;
                  private String userPassword;
                  
                  @Id
                  @Column(name="USERID", nullable=false)
                  public String getUserId() {
                      return userId;
                  }
                  public void setUserId(String userId) {
                      this.userId = userId;
                  }
                  @Column(name="USERPASSWORD", nullable=false)
                  public String getUserPassword() {
                      return userPassword;
                  }
                  public void setUserPassword(String userPassword) {
                      this.userPassword = userPassword;
                  }
                   }
                  

                  查看

                  public class LoginAction extends ActionSupport
                  {
                     private Login bean;
                  public String login()
                  {
                      LoginManager manager=new LoginManager();
                          try
                          {
                              manager.add(getBean());
                          }
                          catch(Exception e)
                          {
                              System.out.println(e.getMessage());
                          }
                           return "success";
                  } 
                  
                  
                  public Login getBean() {
                      return bean;
                  }
                  
                  public void setBean(Login bean) {
                      this.bean = bean;
                  }
                  

                  拦截器

                  public class LoggingInterceptor implements Interceptor
                  {
                  public void destroy() 
                  {
                      System.out.println("Destorying......");
                  }
                  
                  public void init() {
                      System.out.println("Initializing......");
                  
                  }
                  
                  public String intercept(ActionInvocation actionInvocation) throws Exception 
                  {
                      ActionConfig config  = actionInvocation.getProxy().getConfig();  
                      Map parameters       = config.getParams();  
                      String menuId        = (String)parameters.get("userId");
                      System.out.println("Got it:"+menuId);
                              return actionInvocation.invoke();
                  }
                  

                  }

                  推荐答案

                  此代码应该为您提供来自 servlet 请求的参数.假设您有一个参数值.

                  This code should give you parameters from the servlet request. Assume you have one value for the parameter.

                  public String intercept(ActionInvocation actionInvocation) throws Exception 
                  {
                      Map<String, String[]> parameters = ServletActionContext.getRequest().getParameterMap();  
                      String userId  = parameters.get("bean.userId")[0];
                      System.out.println("Got it:"+userId);
                      return actionInvocation.invoke();
                  }
                  

                  这篇关于Struts 2.0 中登录时使用的拦截器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                • <i id='iwP9Q'><tr id='iwP9Q'><dt id='iwP9Q'><q id='iwP9Q'><span id='iwP9Q'><b id='iwP9Q'><form id='iwP9Q'><ins id='iwP9Q'></ins><ul id='iwP9Q'></ul><sub id='iwP9Q'></sub></form><legend id='iwP9Q'></legend><bdo id='iwP9Q'><pre id='iwP9Q'><center id='iwP9Q'></center></pre></bdo></b><th id='iwP9Q'></th></span></q></dt></tr></i><div id='iwP9Q'><tfoot id='iwP9Q'></tfoot><dl id='iwP9Q'><fieldset id='iwP9Q'></fieldset></dl></div>

                      <bdo id='iwP9Q'></bdo><ul id='iwP9Q'></ul>

                      <small id='iwP9Q'></small><noframes id='iwP9Q'>

                      <tfoot id='iwP9Q'></tfoot>
                        <tbody id='iwP9Q'></tbody>

                        • <legend id='iwP9Q'><style id='iwP9Q'><dir id='iwP9Q'><q id='iwP9Q'></q></dir></style></legend>