title: Spring - display image on jsp file
body: <p>my model store image described with file name (as String) and data (as byte array). I use Hibernate and here's my model:</p>
  
  <pre><code>@Entity
  public class Image {
  
      private Long id;
      private String name;
      private byte[] data;
  
      @Id
      @GeneratedValue
      @Column(name = "IMAGE_ID")
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      @Column(nullable = false, length = 100)
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Lob
      @Column(nullable = false)
      public byte[] getData() {
          return data;
      }
  
      public void setData(byte[] data) {
          this.data = data;
      }
  }
  </code></pre>
  
  <p>But I want to display my stored image, on web site like:</p>
  
  <pre><code>&lt;img src="${image.data}" alt="car_image"/&gt;
  </code></pre>
  
  <p>How could I do that?</p>
  
  <p>Should I write controller that serve requests for images?</p>
  
  <p>Any code examples?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <pre><code>&lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="viewClass"
          value="org.springframework.web.servlet.view.tiles2.TilesView" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="tilesConfigurer"
      class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;
      &lt;property name="definitions"&gt;
          &lt;list&gt;
              &lt;value&gt;/WEB-INF/configs/tiles.xml&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>