intellij 不解析 JSP 代码检查或自动完成中的 el 变量 [英] intellij not resolving el variables within JSP code inspection or autocomplete

查看:27
本文介绍了intellij 不解析 JSP 代码检查或自动完成中的 el 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总结这里显示的答案 项目:

解决方案

有一种标准方法可以做到这一点,它不是 IntelliJ 特定的.

这里的type属性不需要是具体的类,也可以是接口类型.通常,您会将这些声明放在 JSP/JSPX 文件的开头,以提供类似于模型输入声明"的内容.

实际上,关于 Spring 的原著(Expert One-on-One J2EE Design and Development.)推荐以这种声明方式使用 JSP.至少 7 年来,IntelliJ 一直在为此类页面提供完整的代码补全.

请注意,IntelliJ 中还有其他相关的便利功能:如果一个 EL 变量引用被标记为未定义,您可以按 Alt-Enter 选择一个 QuickFix,这将插入一个类似上面的声明.它甚至会根据您正在访问的属性尝试找出实际类型.

To summarize the answer shown here Code assist in (jsp /jstl) view for Spring MVC model objects in Eclipse is not working for me at all, is there a setting that I need to change ?

I have just downloaded the sample spring-mvc-showcase on github, and it doesn't work out of the box on that project (with either 11.1.3 or EAP 12 version both full enterprise editions), see below (I have no idea where it gets formBean from) :

Here is an example from my own project,the screen shot below (bottom frame) shows my controller adding a string attribute to model and returning correct view name. I would then expect shopString to be offered up as autocomplete option when editing that view, however it is not :

sg is a javascript variable - so great it should be there, but where is "shopString" ?. Is there a setting I need to change or something else I am missing to get this functionality (using 11.1.3 enterprise edition with all the spring plugins).

It is also failing on spring specific variables :

IS their an open source (one of the spring tutorial projects?) where this definitely works ... or is there a setting I need change in my Intellij install (I have tested with a brand new download of the version 12 EAP) ?

One more screenshot below shows all my spring coifg files set up correctly via autodetection, but the code inspections fails ... this is the spring-mvc-showcase project :

解决方案

There's a standard way to do this, which is not IntelliJ-specific.

<jsp:useBean id="someModel" scope="request" type="foo.bar.SomeModelClass"/>

The type attribute here does not need to be a concrete class, it can be an interface type as well. Typically you'd put these declarations at the start of your JSP/JSPX files, to provide something like a "declaration of model inputs".

Using JSPs in such a declarative way was recommended in the original book on Spring, in fact (Expert One-on-One J2EE Design and Development.). IntelliJ has been providing full code completion for such pages since at least 7 years.

Note that there are additional relevant convenience features in IntelliJ: if an EL variable reference is marked as undefined, you can press Alt-Enter to select a QuickFix, which will insert a declaration like above. It will even try to figure out the actual type, based on the properties you're accessing.

这篇关于intellij 不解析 JSP 代码检查或自动完成中的 el 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆