title: Model Attributes null with Thymeleaf-spring boot
body: <p>I have a weird error that is driving me crazy.
  I have a Controller with two different Get Methods - for two different url mappings.
  URL1 works perfectly fine, with URL2, I get </p>
  
  <blockquote>
    <p>[THYMELEAF][http-nio-8080-exec-3] Exception processing template 
       "questionnaireForm": Error during execution of processor 
      'org.thymeleaf.standard.processor.attr.StandardEachAttrProcessor' 
       (questionnaireForm:10)
    caused by
       java.lang.NullPointerException: null at org.thymeleaf.context.WebSessionVariablesMap.hashCode(WebSessionVariablesMap.java:276) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]</p>
  </blockquote>
  
  <p>After hours of checking each line, it's clear that my Controller Get Method is adding a non-null object to the Model.addAttribute before calling the view.
  I've also removed all of my code from the template and just added the following to troubleshoot:</p>
  
  <pre><code>&lt;tr th:each="var : ${#vars}"&gt;
  &lt;td th:text="${var.key}"&gt;&lt;/td&gt;
  &lt;td th:text="${var.value}"&gt;&lt;/td&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is returning the same null error as well!
  The only thing i could find on the web was a bug with Thymeleaf 2.1.4 that was caused by not having a HttpSession Object
  <a href="https://github.com/thymeleaf/thymeleaf/issues/349" rel="nofollow">https://github.com/thymeleaf/thymeleaf/issues/349</a></p>
  
  <p>but then again, my URL1 works fine!
  I haven't posted any code here because I'm not sure what else to post, please ask!</p>
  
  <p>EDIT: Added Controller Code. <code>/admin/questions</code> is URL1 that works fine, '/admin/questionnaires' is URL2 that doesn't work.</p>
  
  <pre><code>@Controller
  public class AdminController {
  private QuestionRepository questionRepository;
  private EQuestionnaireRepository eQuestionnaireRepository;
  private EQuestionnaire eQuestionnaire;
  
  
  @Autowired
  public AdminController(QuestionRepository questionRepository,
                         EQuestionnaireRepository
                         eQuestionnaireRepository){
      this.questionRepository = questionRepository;
      this.eQuestionnaireRepository = eQuestionnaireRepository;
      eQuestionnaire = eQuestionnaireRepository.findAll().get(0);
  
  }
  
  @RequestMapping(value = "/admin/questions", method=RequestMethod.GET)
          public String questionForm(Model model) {
          model.addAttribute("question", new Question());
          return "questionForm";
  
  }//--&gt;This Works fine
  
  @RequestMapping(value = "/admin/questions", method=RequestMethod.POST)
  public String saveQuestion(@ModelAttribute Question newQuestion, BindingResult bindingResult, Model model) {
      if( bindingResult.hasErrors())
      {
          System.out.println(bindingResult);
          System.out.println("BINDING RESULTS ERROR");
          return "questionForm";
      }
      questionRepository.save(newQuestion);
      return "questionForm";
  }
  
  @RequestMapping(value = "/admin/Questionnaires", method=RequestMethod.GET)
  public String QuestionnaireForm(Model model){
  model.addAttribute("ListofQ",eQuestionnaire.getQuestionList());
      return "questionnaireForm";
  </code></pre>
  
  <p>UPDATE: I changed over to thymeleaf 2.1.5-SNAPSHOT, and now I'm not getting the previously mentioned error - but a different error:</p>
  
  <pre><code>There was an unexpected error (type=Internal Server Error, status=500).
  Exception evaluating SpringEL expression: "ask.questionText"     
  (questionnaireForm:13)
  </code></pre>
  
  <p>So now, the object reference is null in the template. It's not null when i put it into the Model (i've got System.out of the getQuestionText method inside the GET method, so thats confirmed) 
  This is the simple code I'm trying in the template:</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr th:each= "ask : ${ListofQ}"&gt;&lt;/tr&gt;
    &lt;tr th:text= "${ask.questionText}"&gt;&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Here is the Question Object:</p>
  
  <pre><code>@Entity
  @Table(name = "Questions")
  public class Question {
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private Long ID;
  private int sequence;
  private String questionText;
  private int weightage;
  private String option1 = "option1";
  private String option2 = "option2";
  private String option3 = "option3";
  
  public Question() {
  
  }
  public Long getID() {
      return ID;
  }
  public void setID(Long iD) {
      ID = iD;
  }
  
  public int getSequence() {
      return sequence;
  }
  public void setSequence(int sequence) {
      if (sequence &gt; 0) this.sequence = sequence;
  }
  public String getQuestionText() {
      return questionText;
  }
  public void setQuestionText(String questionText) {
      this.questionText = questionText;
  }
  public int getWeightage() {
      return weightage;
  }
  public void setWeightage(int weightage) {
      this.weightage = weightage;
  }
  
  public void setOption1(String option1) {
      this.option1 = option1;
  
  }
  public void setOption2(String option2) {
      this.option2 = option2;
  
  }
  public void setOption3(String option3) {
      this.option3 = option3;
  
  }
  public String getOption1() {
      return option1;
  }
  public String getOption2() {
      return option2;
  }
  public String getOption3() {
      return option3;
  }
  </code></pre>