I'm new in Spring-MVC and I am trying to display a class property that is being assigned to the model.
I am doing the following with a simple string:
model.addAttribute("user", "username" );
And it is being display as expected using:
<P> The user is ${username}. </P>
But now I have the following class:
public class User {
private String name;
public User(){
this.setName("Unknown");
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
And I am trying to display the "Name" property in jsp output without success:
User myuser = new User();
myuser.setName("CARLOS");
model.addAttribute("user",myuser);
In jsp view I am using:
<p>User name is ${user.Name}</p>
Also tried with:
<c:out value="${$user.Name}"></c:out>
How can I achieve it?.