JSP programming problems encountered in the foreground transfer parameters

Source: Internet
Author: User
Tags define get

If you need to send a list to the JSP interface in the background

Write this in the Java file

list<user> albums = new arraylist<user> ();

..

Albums.add (user);

..

Request.setattribute ("albums", albums);

Traverse a linked list in a JSP file

<c:foreach items= "${albums}" var= "album" >
<tr>
<td>${album.albumname}</td>
<td>${album.disc}</td>
<td>${album.date}</td>
<td>${album.name}</td>

</tr>
</c:forEach>

However, the operation will cause an inexplicable error:

Org.apache.jasper.JasperException:javax.el.PropertyNotFoundException:Property ' albumname ' not readable on type Webalbum.user

Return to User.java view, the albumname variable is actually defined, but it will also produce this error ...

After a long exploration, we found that we had to define get in the User.java file ... function to use the corresponding variable in the JSP file

For the example above, you have to define four return functions:

public string Getalbumname ()

{

return albumname;

}

public string Getdisc ()

{

return disc;

}

public string getdate ()

{

return date;

}

public string GetName ()

{

return name;

}

At this point the JSP page can display the contents of the linked list normally. Problem solving

JSP programming problems encountered in the foreground transfer parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.