JSP EL and autoCompletion

2019-03-25 04:46发布

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 an item.address in IDE (IntelliJ)?
Can I use <jsp:useBean> for any other feature to make the type of 'item' explicit?

1条回答
男人必须洒脱
2楼-- · 2019-03-25 05:11

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.

查看更多
登录 后发表回答