Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在eclipse中将ReactJs与Spring MVC集成_Eclipse_Reactjs_Spring Mvc - Fatal编程技术网

如何在eclipse中将ReactJs与Spring MVC集成

如何在eclipse中将ReactJs与Spring MVC集成,eclipse,reactjs,spring-mvc,Eclipse,Reactjs,Spring Mvc,在客户端使用angularJS之前,我是ReactJS的新手。但是现在我想在SpringMVC上将它与当前的应用程序集成。现在我想集成ReactJS作为客户端,而不是angularJS,请帮助我。如果有任何例子,请帮助。我正在使用eclipseide创建一个视图(jsp/html/xhtml),并将UI构建输出链接到该视图。您可以使用webpack作为UI(React)的构建工具,UI(React)将返回bundle文件 然后可以使用脚本标记将其包含在视图中。请注意,您可以使用WebpackDe

在客户端使用
angularJS
之前,我是
ReactJS
的新手。但是现在我想在
SpringMVC
上将它与当前的应用程序集成。现在我想集成
ReactJS
作为客户端,而不是
angularJS
,请帮助我。如果有任何例子,请帮助。我正在使用eclipseide创建一个视图(jsp/html/xhtml),并将UI构建输出链接到该视图。您可以使用webpack作为UI(React)的构建工具,UI(React)将返回bundle文件

然后可以使用脚本标记将其包含在视图中。请注意,您可以使用WebpackDevServer进行UI开发,并尝试使用代理来使用SpringMVC服务。这是一个推荐的方法。如果您使用Maven作为java构建工具,则可以使用包含webapp下所有JS的文件夹

网页参考:

示例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/clientcode/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')
        }
    }
};