如何使用 Spring 框架安装 React js?

How to install React js with Spring framework?

我不知道如何为 Spring 框架安装 React.js。

某网站说要先安装NPM。是的,我做到了。

但是如何在 Spring MVC 中使用 React.js?

  1. mac和windows需要安装NPM吗?
  2. 只使用CDN -> 这种情况发生错误
  3. 如何搜索基础课程
  4. 只使用 spring 引导?
  5. 能否给个网址,如何安装Spring React.js
  6. 的框架
  7. 你能告诉我如何为 Spring 安装 React.js 的提示吗 框架?

我是开发新手。

我能给你的最佳答案是逐步完成本教程。

https://spring.io/blog/2015/09/01/react-js-and-spring-data-rest-part-1-basic-features

要回答您的第一个问题,不,您不需要使用 node.js 工具来将 React 与 Spring MVC 结合使用。上面的教程说:

This tutorial won’t go into extensive detail on how it uses require.js to load JavaScript modules. But thanks to the frontend-maven-plugin, you don’t have to install any of the node.js tools to build and run the code.

Spring MVCReactJS 遵循设计 Web 应用程序的一些不同概念。使用 Spring MVC,你创建的大部分时间是服务器端渲染的 web 应用程序,使用 JSPs 或者你使用像 Thymeleaf 这样的模板引擎。

使用 ReactJS 您正在构建一个单页应用程序 (SPA),可以使用 SINGLE HTML 文件访问,通常 index.html 而你的 JavaScript 正在做渲染。使用 Spring MVC,您提供多个 .html 文件,并使用 Spring 将不同的路由路由到不同的 .html 文件,并在服务器端呈现它们。

我唯一能猜到的是为你最终构建的 ReactJS 提供服务,它只包含一个 .html 和几个 .js 以及其他带有 Spring MVC 的资产应用程序就像一个简单的网络服务器。

此外,您可以使用 Spring MVC 为您的 React 应用程序提供 RESTful 接口。