title: Spring MVC - Creating Custom List Dynamically
body: <p>I am trying to create a custom list from Spring MVC. </p>
  
  <p>The main issue is I can't find any great sources on how to create a custom list... But here is the design I want and some code I have already. </p>
  
  <p><strong>Design</strong>
  <a href="https://i.stack.imgur.com/YHU33.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YHU33.png" alt="enter image description here"></a></p>
  
  <p><strong>Code</strong></p>
  
  <p>JSP frontpage.jsp</p>
  
  <pre><code>&lt;div id="result-panel"&gt;
              &lt;ul&gt;
              &lt;c:forEach var="listValue" items="${offenderlists}"&gt;
                  &lt;li&gt;OffenderId: &lt;c:out value="${listValue.offenderId}"/&gt; &lt;li&gt;
                  &lt;/c:forEach&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Java controller</p>
  
  <pre><code>@RequestMapping(value = "/", method = RequestMethod.POST)
      public String someMethod(@RequestParam("intelvalue") String valueOne) {
          ApplicationContext context = 
                  new ClassPathXmlApplicationContext("Spring-Module.xml");
              OffenderDAO offenderDAO = (OffenderDAO) context.getBean("offenderDAO");
              Offender[] offenders = null;
  
              try {
                  offenders = offenderDAO.requestOffenders(valueOne);
              } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace(); 
              }
              for(Offender o: offenders) 
                  System.out.println("offender: "+ o.OffenderId);
              ModelAndView model = new ModelAndView("frontpage");
              model.addObject("offenderlists", offenders);
              // Returned the list of offenders to jsp here...
              return "frontpage";
      }
  </code></pre>
  
  <p>I know I am doing it wrong I have in image url in the offender object along with everything I need I have no issues loading the offenders from my database. How do I create a list of offenders as show in design?</p>
  
  <p><strong>QUESTION</strong>
  How to create what is show in design with Spring MVC Models? Offender objects are loaded and data is within the objects I just need to display in list form how would I go at doing such?</p>
  
  <p>References below were viewed and didn't provide a good enough example/answer.
  References: <a href="https://stackoverflow.com/questions/9617207/listfoo-as-form-backing-object-using-spring-3-mvc-correct-syntax?rq=1">List&lt;Foo&gt; as form backing object using spring 3 mvc, correct syntax?</a></p>
  
  <p><a href="http://www.mkyong.com/spring-mvc/spring-mvc-and-list-example/" rel="nofollow noreferrer">http://www.mkyong.com/spring-mvc/spring-mvc-and-list-example/</a></p>