title: How to get URL parameter in prepare method of action class in Struts 2
body: <p>I am getting <code>null</code> as URL parameter name in prepare method of <code>Preparable</code> interface, while parameter is set in URL.</p>
  <p>URL I am trying to visit,</p>
  <pre><code>http://localhost:8080/basic-struts/registerInput.action?userid=1
  
  
  public class Register extends ActionSupport implements Preparable {    
  
      private String userid;       
  
      public void prepare() throws Exception {
          // Call the service, load data, 
          // every time even if validation fails
  
          System.out.println(&quot;----------&quot;);
          System.out.println(userid); //&lt;-------null
          System.out.println(&quot;----------&quot;);
      }
  
      public String getUserId() {
          return userid;
      }
  
      public void setUserId(String userid) {
          this.userid = userid;
      }
  
  }
  </code></pre>
  <p>Note :- I get some error in logs as follows,</p>
  <blockquote>
  <p>2021-07-01 09:28:53,929 ERROR [qtp1182469998-22] interceptor.ParametersInterceptor (ParametersInterceptor.java:238) - Developer Notification (set struts.devMode to false to disable this message):
  Unexpected Exception caught setting 'userid' on 'class org.apache.struts.register.action.Register: Error setting expression 'userid' with value ['1', ]</p>
  </blockquote>