title: javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String
body: <p>I'm getting the error above.</p>
  
  <p>What i'm trying to do is write an app that takes in an unknown number of names, then prints them out on a new page. This is supposed to be for a bowling scoring app, but for now I just want to get a list of names. The idea is for each name to go into a player object, then in turn be stored in the players arraylist. If anyone can help, I would appreciate it.</p>
  
  <p>This is my controller code:</p>
  
  <pre><code>package multiplayergame;
  
  import java.util.ArrayList;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.validation.BindingResult;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.SessionAttributes;
  import org.springframework.web.servlet.ModelAndView;
  
  
  @Controller
  @SessionAttributes
  public class MultiplayerController {
  
  int score;
  int roll;
  Game game = new Game();
  GameProperties gameProps = new GameProperties();
  int playerNo = 0;
  
  ArrayList&lt;PlayerGame&gt; players = new ArrayList&lt;&gt;();
  PlayerGame player;
  
  @RequestMapping(value = "/home", method = RequestMethod.GET)
  public ModelAndView home() {
  
      return new ModelAndView("home", "command", gameProps);      
  }
  
  @RequestMapping(value = "/nextName", method = { RequestMethod.POST, RequestMethod.GET})
  public ModelAndView homeNext(MContact mcontact, BindingResult result) {     
      player = new PlayerGame();
  
      player.setName(mcontact.getName());
      players.add(player);
      gameProps.setPlayers(players);
      playerNo++;
      return new ModelAndView("home", "command", gameProps);      
  }
  
  @RequestMapping(value = "/test", method = RequestMethod.POST)
  public ModelAndView playNext(GameProperties gameProps2, ModelMap model) {
  
      model.addAttribute("players", gameProps.getPlayers());
      model.addAttribute("name", gameProps.getPlayers().get(playerNo).getName());
  
      return new ModelAndView("test", "players", gameProps2);
  
  }
  }
  </code></pre>
  
  <p>This holds details for each player:</p>
  
  <pre><code>package multiplayergame;
  
  public class PlayerGame {
  private int score;
  private int pins;
  private String name;
  private int roll;
  private int nOfPlayers;
  private int playerNo;
  
  
  Game game = new Game();
  
  public Game getGame() {
      return game;
  }
  public void setGame(Game game) {
      this.game = game;
  }   
  public int getScore() {
      return score;
  }
  public void setScore(int score) {
      this.score = score;
  }
  public int getPins() {
      return pins;
  }
  public void setPins(int pins) {
      this.pins = pins;
  }
  public String getName() {
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }   
  public int getRoll() {
      return roll;
  }
  public void setRoll(int roll) {
      this.roll = roll;
  }
  public int getnOfPlayers() {
      return nOfPlayers;
  }
  public void setnOfPlayers(int nOfPlayers) {
      this.nOfPlayers = nOfPlayers;
  }
  public int getPlayerNo() {
      return playerNo;
  }
  public void setPlayerNo(int playerNo) {
      this.playerNo = playerNo;
  }
  }
  </code></pre>
  
  <p>This is the code for all Game properties, such as scoring etc.</p>
  
  <pre><code>package multiplayergame;
  
  import java.util.ArrayList;
  
  public class GameProperties {
  
  private int score;
  private int pins;
  private String name;
  private int roll;
  private int nOfPlayers;
  PlayerGame player;
  private ArrayList&lt;PlayerGame&gt; players;
  private int playerNo;
  
  public int getScore() {
      return score;
  }   
  public void setScore(int score) {
      this.score = score;
  }   
  public int getPins() {
      return pins;
  }
  public void setPins(int pins) {
      this.pins = pins;
  }
  public String getName() {
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }
  public int getRoll() {
      return roll;
  }
  public void setRoll(int roll) {
      this.roll = roll;
  }
  public int getnOfPlayers() {
      return nOfPlayers;
  }
  public void setnOfPlayers(int nOfPlayers) {
      this.nOfPlayers = nOfPlayers;
  }
  public ArrayList&lt;PlayerGame&gt; getPlayers() {
      return players;
  }
  public void setPlayers(ArrayList&lt;PlayerGame&gt; players) {
      this.players = players;
  }
  public int getPlayerNo() {
      return playerNo;
  }
  public void setPlayerNo(int playerNo) {
      this.playerNo = playerNo;
  }   
  }
  </code></pre>
  
  <p>The following are my JSP files, the output first:</p>
  
  <pre><code>&lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Test output&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h2&gt;Test Roll&lt;/h2&gt;
  
  &lt;c:forEach var="player" items="players"&gt;
  Name &lt;c:out value="${player.name}"/&gt;&lt;p&gt;
  &lt;/c:forEach&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the home page:</p>
  
  <pre><code>&lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Bowling&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Welcome players!&lt;/h2&gt;
  
  &lt;h2&gt;Please enter your names.&lt;/h2&gt;
  
  &lt;form:form method="post" action="/multiplayergame/nextName"&gt;
  
  &lt;table&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;form:label path="name"&gt;Name&lt;/form:label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;form:input path="name" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td colspan="2"&gt;
          &lt;input type="submit" name = "button" value="Next Player"/&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;     
  &lt;/form:form&gt;
  &lt;form:form method="post" action="/multiplayergame/test"&gt;
  &lt;tr&gt;
      &lt;td colspan="2"&gt;
          &lt;input type="submit" name = "button" value="Play"/&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>