Vaadin 和 Spring MVC 集成

发布于 2024-07-30 03:17:11 字数 202 浏览 3 评论 0原文

我正在考虑将 Spring MVC 与 Vaadin 框架一起使用的可能性。 是否有任何记录在案的方法可以使它们很好地协同工作? 另外,将它们一起使用是个好主意吗? 与表现有关; 我将在专用服务器上运行该应用程序。

为了让我的问题更清楚一些,我如何从 Spring MVC 控制器返回模型和视图,该控制器将使用 Vaadin 渲染并可以访问所有模型数据。

I'm thinking about the possibility of using Spring MVC with Vaadin Framework. Are there any documented ways of making them play nicely together ? Also is it a good idea to use them together ? relating to performance; I'm going to run the app on a dedicated server.

To make my question a bit more clear, how can i return a modelandview from a Spring MVC Controller that wll render using Vaadin and can access all the model data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

败给现实 2024-08-06 03:17:11

Spring 对 Vaadin 的支持是相当新的,但最近论坛上有很多关于它的讨论,并且有些人已经对其进行了测试。 似乎有效。 Vaadin wiki 上有一篇关于它的文章,论坛上有一些讨论 Vaadin + Spring 集成的帖子:

Wiki:Spring 集成
论坛:it mill工具包能否与spring应用集成
论坛:Spring集成问题
论坛:使用 Spring
论坛:Spring 集成

Spring support for Vaadin is quite new, but there has recently been a lot of talk about it on the forum and some have tested it. Seems to work. There is an article on the Vaadin wiki about it, and some threads on the forum talking about Vaadin + Spring integration:

Wiki: Spring Integration
Forum: can it mill toolkit be integrated with spring application
Forum: Spring integration problem
Forum: Working with Spring
Forum: Spring Integration

緦唸λ蓇 2024-08-06 03:17:11

不确定将 vaadin 与 Spring MVC 集成是否是一个谨慎的选择。 这是一种浪费。 MVC 适用于典型的基于页面的 Web 应用程序,而 vaadin 则更多地基于视图状态,就像桌面应用程序一样。 我通常会在中间进行会面,并在 Spring 中设置我的业务层和数据访问层,并按原样使用 Vaadin。

Not sure if it is a prudent choice to integrate vaadin with Spring MVC. Its a waste. MVC is meant for typical page based web apps where as vaadin is more view state based like a desktop app. I would typically do a meet in the middle and have my business tier and data access layer in spring and use Vaadin as is.

生来就爱笑 2024-08-06 03:17:11

请参阅 Vaadin 论坛上的此帖子了解我的 AutowiringApplicationServlet 解决方案,包括示例 WAR 应用程序。

See this thread on the Vaadin forum for my AutowiringApplicationServlet solution, including a sample WAR application.

爱本泡沫多脆弱 2024-08-06 03:17:11

同意 dhrbo 的意见。

使用 spring mvc 并不明智,使用 webflow 和 vaadin 更是如此。 vaadin 是另一个网络应用程序框架。

如果您想在 vaadin 项目中使用“spring mvc”的想法,请将其与 spring-core、bean 和 context 集成。 这样你就可以清楚地分离控制器、ui (vaadin) 和模型(与 hibernate / orms 集成)

agreed with dhrbo.

its not wise to use spring mvc, more so with webflow with vaadin. vaadin is another web-app framework.

if you want the idea of "spring mvc" in your vaadin project, integrate it with spring-core, beans and context. that way you can get a clear separation between controllers, ui (vaadin), and models (integrate with hibernate / orms)

三寸金莲 2024-08-06 03:17:11

这里有一篇关于Spring服务层与Vaadin集成的文章。 它与最初问题所涉及的 Spring MVC 没有直接关系,但它仍然可以为其他研究 Vaadin Spring 集成的读者提供参考。

http://psponcoding.blogspot.com/2011/03/vaadin-spring -integration.html

Here's an article on integrating Spring service layer with Vaadin. It does not directly relate to Spring MVC that the original question was about, but it can still be a pointer for other readers researching Vaadin Spring integration.

http://psponcoding.blogspot.com/2011/03/vaadin-spring-integration.html

酷遇一生 2024-08-06 03:17:11

org.springframework.web.servlet.mvc.Controller的handleRequest采用HttpServletRequestHttpServletResponse作为参数。 您无法从这些中处理 URI 片段。 因此,控制器不适合基于 URI 片段控制请求。

在我的应用程序中,我实现了与 Spring 控制器非常相似的概念。 我的应用程序仍然有“视图”和“模型”的概念。 每个视图都在单独的类中实现,并显示在页面的中央块中。 我想将 URL 处理的逻辑集中到该类中,因此我创建了一个类 AbstractControllerEntry

public static abstract class AbstractControllerEntry {
    public abstract boolean matches(String fragment);
    public abstract void open(MainWindow window, String fragment);
}

带有几个方便的子类,例如 ConstantEntryPrefixEntry和RegexEntry。

每个视图类都有一个静态方法,该方法返回AbstractControllerEntry。 所有条目的集合都保存在 MyController 类(不是 Spring MVC 控制器)内的静态数组中。 片段更改后(请参阅 UriFragmentUtility),我迭代所有条目,并为首先,哪个匹配,我将调用 open。 任何其他逻辑(例如查找模型对象)都位于视图类内部的 AbstractControllerEntry 实现中。

另外,还有另一个静态方法可以在视图类中生成 URI 片段,以便对视图的每个引用都是对类的真正引用,这是链接损坏的解决方案。 每个视图都有实例方法来获取当前视图的片段,检查该片段是否与控制器条目匹配以提高鲁棒性。

org.springframework.web.servlet.mvc.Controller's handleRequest takes a HttpServletRequest and HttpServletResponse as parameters. From these, you cannot process the URI fragment. As such, the controller is not suited for controlling requests based on URI fragment.

In my application, I implemented very similar concept to Spring controller. My application still has a notion of "views" and "model". Each view is implemented in a separate class and is displayed in a central block of the page. I wanted to centralize logic of the URL processing to that class, so I created a class AbstractControllerEntry:

public static abstract class AbstractControllerEntry {
    public abstract boolean matches(String fragment);
    public abstract void open(MainWindow window, String fragment);
}

with several convenience subclasses such as ConstantEntry, PrefixEntry and RegexEntry.

Each view class has a static method, that returns AbstractControllerEntry. Collection of all entries is kept in a static array inside of MyController class (not a Spring MVC controller). Upon fragment change (see UriFragmentUtility), I iterate all entries, and for first, which matches, I will call open. Any other logic, such as finding the model object, is inside of the view class, in the AbstractControllerEntry implmentation.

Additionaly, there's another static method to generate the URI fragment in the view class, so that each reference to a view is a real reference to a class, this is a solution to broken links. And each view has instance method to get a fragment for current view, which is checked to match a controller entry to increase robustness.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文