您可以在 Java EE Web 应用程序中实现 Vue.js 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40897615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 05:33:03  来源:igfitidea点击:

Can you implement Vue.js in a Java EE web application?

javajakarta-eetomcat7vue.js

提问by IFreshman

I just develop a tool with my classmates and we want to use Vue.js as Web interface.

我只是和我的同学一起开发了一个工具,我们想使用 Vue.js 作为 Web 界面。

For Description what we programmed. We developed a Java EE web application in Eclipse. We use Tomcat 7 as web server. I search a long time and i found nothing.

对于描述我们编程的内容。我们在 Eclipse 中开发了一个 Java EE Web 应用程序。我们使用 Tomcat 7 作为 Web 服务器。我搜索了很长时间,但一无所获。

回答by Chetan Jadhav CD

Vue.js is a javascript front-end framework. There is nothing to stop you from using that with a middle-layer/back-end technology like Java EE. In your HTML pages(or JSP) just include the Vue.js file as mentioned in the documentation, and other .js files that you create as part of your vue.js frontend application.

Vue.js 是一个 javascript 前端框架。没有什么可以阻止您将其与 Java EE 等中间层/后端技术结合使用。在您的 HTML 页面(或 JSP)中,只需包含文档中提到的 Vue.js 文件,以及您作为 vue.js 前端应用程序的一部分创建的其他 .js 文件。

The library can then interface with any HTTP-based backend methods that you expose (using Servlets, Controllers, etc.) depending on how your Java EE project is structured and what frameworks it uses.

然后,该库可以与您公开(使用 Servlet、控制器等)的任何基于 HTTP 的后端方法交互,具体取决于您的 Java EE 项目的结构方式及其使用的框架。

回答by Tristan

For sure you can.

你肯定可以。

Your java application, which is your "backend", has to expose its functionalities as Web services (REST Json WS should be the easiest for what you are trying to do).

您的 java 应用程序,即您的“后端”,必须将其功能公开为 Web 服务(REST Json WS 应该是您尝试做的最简单的方法)。

To expose your services as Web services, you need to find the easiest framework fitting your need. You will probably need to dive into Maven if you haven't yet, because these frameworks tend to have tons of dependencies.

要将您的服务公开为 Web 服务,您需要找到适合您需要的最简单的框架。如果您还没有,您可能需要深入研究 Maven,因为这些框架往往有大量的依赖项。

Your Vue.js interface will make calls to the backend via HTTP requests each time necessary (get a resource, update a resource, ...).

您的 Vue.js 接口将在每次必要时通过 HTTP 请求调用后端(获取资源、更新资源……)。

回答by ASH

While investigating the same question, I found this good blog that has a git repository too https://blog.codecentric.de/en/2018/04/spring-boot-vuejs/

在调查同样的问题时,我发现这个很好的博客也有一个 git 存储库 https://blog.codecentric.de/en/2018/04/spring-boot-vuejs/

From a glance it looks like a read solid implementation, however it has some sticky setup i haven't come across before. It dose however seem like a professional and scalable solution i will definitely give a try. https://github.com/jonashackt/spring-boot-vuejsThankyou 04/24/18 by Jonas Hecht

乍一看,它看起来像是一个可靠的实现,但是它有一些我以前从未遇到过的粘性设置。然而,它似乎是一个专业且可扩展的解决方案,我一定会尝试一下。 https://github.com/jonashackt/spring-boot-vuejs谢谢 04/24/18 乔纳斯赫克特