Rejeev Divakaran
Rejeev Divakaran

Reputation: 4504

JSP EL and autoCompletion

In my servlet:

request.setAttribute("list", myList);

In my JSP:

<c:forEach var="item" items="${list}">
   ${item.name} and ${item.address}
</c:forEach>

How do I get autocompletion for item.name and item.address in an IDE, specifically in IntelliJ IDEA?

Can I use <jsp:useBean> for any other feature to make the type of item explicit?

Upvotes: 16

Views: 8590

Answers (1)

Steven Benitez
Steven Benitez

Reputation: 11055

For IntelliJ, you can use comment annotations, such as this:

<%--@elvariable id="list" type="java.util.List<your.item.class.Here>"--%>

To get this automatically, IntelliJ should be coloring ${items} as a warning, since it wont have any idea what it is. Click on it and when the lightbulb pops up, click the option "Declare external variable in comment annotation." That will generate a comment annotation such as the one listed above.

Upvotes: 29

Related Questions