Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 861
Xorty Avatar asked Dec 27 '22 01:12

Xorty


1 Answers

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.

like image 127
Sean Patrick Floyd Avatar answered Dec 31 '22 11:12

Sean Patrick Floyd