栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Eclipse中将ReactJ与Spring MVC集成

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Eclipse中将ReactJ与Spring MVC集成

尝试创建一个视图(jsp / html / xhtml)并将UI构建输出链接到该视图。您可以将 webpack
用作UI(React)的构建工具,该工具将返回捆绑文件。

然后可以将其包含在内以使用脚本标签进行查看。请注意,您可以使用webpack-dev-server进行UI开发,并尝试使用Proxy来使用spring-
mvc服务。它是推荐的方式。如果您使用 Maven 作为Java的构建工具,则可以使用包含webapp下所有JS的文件夹。

webpack参考:https
://webpack.js.org/

示例 Webpack.config.js 供参考。

const ExtractTextPlugin = require('extract-text-webpack-plugin');const path = require('path');const webpack = require('webpack');module.exports = {    entry: {        main: './src/scripts/main.js',        engine: './src/scripts/engine/Engine.js',        debugger: './src/scripts/debug/Debugmain.js',        client: './src/scripts/clientpre/Client.js'    },    output: {        path: path.resolve('./dist/client'),        filename: '[name].js',        publicPath: '/dist/client/',        chunkFilename: '[name].js'    },    devtool: 'inline-sourcemap',    cache: true,    resolve: {        alias: { ByteBuffer: 'bytebuffer' }    },    module: {        rules: [ {     test: /.js$/,     exclude: /(node_modules|bower_components)/,     loader: 'react-hot-loader' }, {     test: /.js$/,     exclude: /(node_modules|bower_components)/,     loader: 'babel-loader',     query: {         cacheDirectory: true,         presets: ['react', 'es2015'],         compact: false     } }, {     enforce: 'pre',     test: /.(js|jsx)$/,     exclude: /node_modules/,     include: [path.join(__dirname, './src', 'scripts')],     loader: 'eslint-loader' }, {     test: /.less$/,     loader: ExtractTextPlugin.extract({         fallback: 'style-loader',         loader: 'css-loader?sourceMap!less-loader?sourceMap'     }) }, {     test: /.(eot|woff|woff2|ttf|otf|png|jpg)$/,     loader: 'file-loader?name=images/[name].[ext]' }        ]    },    devServer: {        port: 8080,        stats: 'errors-only',        proxy: { '/api': {     target: 'http://localhost:20404', //http://localhost:20403/',     secure: false }        },        historyApiFallback: { index: 'debug.html'        }    },    plugins: [        new ExtractTextPlugin({ filename: './styles/main.css', allChunks: true        })    ],    resolve: {        modules: ['src/scripts', 'node_modules'],        extensions: ['.jsx', '.js'],        unsafeCache: true,        alias: { components: path.resolve(__dirname, 'src', 'scripts', 'components'), routes: path.resolve(__dirname, '.', 'routes'), draggable_tab: path.resolve(__dirname, 'src', 'scripts', 'lib'), utils: path.resolve(__dirname, 'src', 'scripts', 'utils'), engine: path.resolve(__dirname, 'src', 'scripts', 'engine')        }    }};


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/379313.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号