title: How do I add attributes to http request to spring controller?
body: <p>I would like to test the spring controller below, which reads <code>http request attributes</code> and acts on them.  I am able to trigger the controller code below by typing <code>localhost:8080/someURL</code> into my web browser.  But the result is <code>{"id":1,"content":"null and null and null"}</code>, which indicate <code>null</code> values in the named <code>request attributes</code>.  <strong>How do I send a request to a named url like <code>localhost:8080/someURL</code> which contains values for the specified <code>request attributes</code>, so that I can confirm that the receiving controller code works properly?</strong></p>
  
  <p>Here is the code for the controller:  </p>
  
  <pre><code>import java.util.concurrent.atomic.AtomicLong;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestPa    ram;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import javax.servlet.http.HttpServletRequest;
  
  @Controller
  public class SomeController {
  
      private final AtomicLong counter = new AtomicLong();
  
      @RequestMapping(value = "/someURL", method=RequestMethod.GET)
      public @ResponseBody Greeting receiveSMS(HttpServletRequest req){
          String att1 = (String) req.getAttribute("att1");
          String att2 = (String) req.getAttribute("att2");
          String att3 = (String) req.getAttribute("att3");
          String total = att1 + " and " + att2 + " and " + att3;
          return new Greeting(counter.incrementAndGet(), String.format(total));
      }
  
      }  
  </code></pre>
  
  <p>Note:  I am trying to recreate in Spring <a href="https://www.twilio.com/help/faq/sms/how-can-i-forward-sms-to-my-email-inbox" rel="nofollow">the PHP functionality that is given in the script at the following link</a>.  I have not written this kind of code below, if I am framing the question poorly, I would appreciate advice for reframing it.  Along with a link to any example solution such as a JUNIT or other means by which to recreate the request.</p>