Xorty
Xorty

Reputation: 18861

IntelliJ: Spring MVC beans in JSP pages are not resolved

When I put something in model in spring mvc like this:

@RequestMapping(method = RequestMethod.GET)
public String createForm(Model model) {
    model.addAttribute("item", new Item());
    return "item/new";
}

bean "item" is not resolved by IntelliJ in corresponding JSP pages. I mean, it works perfectly fine, but autocompletion doesn't :/

Is there any way to have autocompletion in such case?

Upvotes: 4

Views: 1664

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298818

IntelliJ's JSP support understands a special kind of comment annotation:

<%--@elvariable id="foo" type="com.yourcompany.YourClass"--%>

If you place this annotation at the top of your file, idea will provide auto completion for expressions starting with ${foo. based on the properties of class com.yourcompany.YourClass

IntelliJ will also offer to create this annotation if you hover over the foo part of an expression.

Upvotes: 11

Related Questions