title: Want to display enum name corresponding to value in jsp
body: <p>I am new to Spring and trying to populate user details in a table, the table will show some basic information of Users of system 
  Structure of table is </p>
  
  <pre><code>Firstname   Lastname    Email   Phone Number    Role    State
  </code></pre>
  
  <p>I am using Spring 4 and Hibernate 4.</p>
  
  <p>My Model class</p>
  
  <pre><code>@Entity
  @Table(name = "USERS")
  public class User {
  
  @Id
      @Column(name = "USER_ID")
      private String userId;
  
      @Column(name = "PASSWORD")
      private String password;
  
      @Column(name = "FIRST_NAME")
      private String firstName;
  
      @Column(name = "MIDDLE_NAME")
      private String middleName;
  
      @Column(name = "LAST_NAME")
      private String lastName;
  
      @Column(name = "EMAIL")
      private String email;
  
      @Column(name = "PHONE")
      private String phone;
  
      @Column(name = "STATE")
      private int state=State.ACTIVE.getState();
  
      @ManyToMany(fetch = FetchType.LAZY)
      @JoinTable(name = "USER_ROLE_MAP", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = {
              @JoinColumn(name = "ROLE_ID") })
      private Set&lt;Role&gt; blogRoles = new HashSet&lt;&gt;();
  
  /*getters and setter and other utility methods are remove*/
  </code></pre>
  
  <p>My Controller method of user list</p>
  
  <pre><code>@RequestMapping(value = "/listUser", method = RequestMethod.GET)
      public ModelAndView showAllUsers() {
          System.out.println("start login");
  
          ModelAndView modelAndView=new ModelAndView("listUser");
  
          List&lt;User&gt; userList=userService.findAll();
          System.out.println("user List controler "+userList);
  
          modelAndView.addObject("currentUser", getPrincipal());
          modelAndView.addObject("userList", userList);
  
          return modelAndView;
      }
  </code></pre>
  
  <p>My Jsp code to display the user list data</p>
  
  <pre><code> &lt;c:forEach items="${userList}" var="user"&gt;
      &lt;tr&gt;
          &lt;td&gt;${user.firstName}&lt;/td&gt;
          &lt;td&gt;${user.lastName}&lt;/td&gt;
          &lt;td&gt;${user.email}&lt;/td&gt;
          &lt;td&gt;${user.phone}&lt;/td&gt;
          &lt;td&gt;
              &lt;c:forEach items="${user.blogRoles}" var="role"&gt;                                                                  
                  ${role.roleType}
              &lt;/c:forEach&gt;
          &lt;/td&gt;
          &lt;td&gt;${user.state}&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>Now I have a enum which has information about the state of user </p>
  
  <pre><code>public enum State {
  
      ACTIVE(1), INACTIVE(2), LOCKED(3), DELETED(4);
  
      private int state;
  
      private State(int state) {
          this.state = state;
      }
  
      public int getState() {
          return state;
      }
  
      @Override
      public String toString(){
          return this.name();
      }
  
      public String getName(){
          return this.name();
      }
  
  }
  </code></pre>
  
  <p>In JSP the <code>state</code> comes as integer</p>
  
  <p>I want to display the <code>name</code>, the string value corresponding to the <code>state</code> which is an integer injected by spring and fetched by hibernate from DB.</p>
  
  <p>I know there are some ways to do it like I can create a map from enum and send it's object to JSP or defining my own custom TLD.</p>
  
  <p>But I am still not satisfied with these kind solutions, is there any better way to display the value with some more standard way or using some features of spring and EL ?</p>
  
  <p>Any suggestion and help will be help full, thanks.</p>