【问题标题】:How to add React build files into existing JSP project如何将 React 构建文件添加到现有 JSP 项目中
【发布时间】:2020-11-02 04:21:52
【问题描述】:

我已经使用一些外部库构建了一个 react 应用程序,并希望将其包含到一个没有放置 JSP 的现有项目中。

运行命令react-scripts build 在构建文件夹中生成文件。

  • build/asset-manifest.json
  • build/favicon.ico
  • build/index.html
  • build/manifest.json
  • build/precache-manifest.23802519359aee1ffa0ec2f3ba332c80.js
  • build/work.js
  • 构建/静态
  • build/tab.png

我应该包含什么以及如何包含这些文件。

我尝试将index.html 添加到index.jsp,但似乎不起作用。虽然我确实看到标题更改为我的反应应用程序中的内容。

<%@include file="index.html"%>

或者我是否需要包含类似于我添加index.html的所有文件

index.html 文件确实会在 build/js 文件夹中加载几个脚本文件,如下所示。

<script src="/static/js/2.57fa75d6.chunk.js"></script><script src="/static/js/main.fe75a1b9.chunk.js"></script>

【问题讨论】:

  • 我还需要通过 CDN 加载 react 吗?

标签: reactjs jsp


【解决方案1】:

我的项目与您的要求相似。 一些信息需要在服务器上呈现,但在 java 中找不到合适的方法,所以我为此创建了 maven 插件:

https://github.com/maasdi/react-assets-maven-plugin

你可以试试看,希望对你有帮助。

【讨论】:

  • 好吧,我看看。感谢您的评论!
猜你喜欢
  • 2018-12-29
  • 1970-01-01
  • 2013-04-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-09
  • 2021-06-02
相关资源
最近更新 更多