Eclipse中Spring MVC模型对象的(jsp / jstl)视图中的代码辅助 [英] Code assist in (jsp /jstl) view for Spring MVC model objects in Eclipse

查看:301
本文介绍了Eclipse中Spring MVC模型对象的(jsp / jstl)视图中的代码辅助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Spring MVC中,在视图模型中放置一个对象,如下所示:

In Spring MVC when placing an object in the view model like so:

public String getUser( Model model ) {
    //...fetch user...
    model.addAttribute( "user", user );
    return "viewName";
}

并在JSP / JSTL视图中访问它的值如下:

and accessing it's values in the JSP / JSTL view like this:

...
<p>
    ${user.name}
</p>
...

我想知道是否可以为代码提供代码帮助用户视图中的对象?

I'm wondering if it is possible to have code assist for the user object in the view?

我正在使用的IDE是MyEclipse,但知道是否会很有趣这在其他编辑器中也是可能的。

The IDE I'm using is MyEclipse but it would be interesting to know if this is possible in other editors as well.

谢谢。

推荐答案

理想情况下,您希望JSP / JSTL标准标记与提供这些对象的技术无关,但您在设计支持时至少是正确的。

Ideally you want the JSP/JSTL standard tags to be agnostic of the technology that supplies these objects but you are correct in that atleast while designing the support will be useful.

然而看起来Intellij IDEA似乎有类似于你想要的东西 http://www.jetbrains.com/idea/features/spring_framework.html (到最后)!

However it looks like Intellij IDEA seems to have something similar to what you want http://www.jetbrains.com/idea/features/spring_framework.html (towards the end)!

您必须添加如下JSP注释:

You have to add a JSP comment like this:

<%--@elvariable id="pet" type="com.mycompany.Pet"--%>

IntelliJ将根据该类型自动完成。

IntelliJ will then autocomplete based on that type.

alt text http://www.jetbrains.com/idea /features/screenshots/80/mvcAttributesCompletion.gif

是否正在使用IntelliJ?

Is using IntelliJ ruled out for you?

这篇关于Eclipse中Spring MVC模型对象的(jsp / jstl)视图中的代码辅助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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