我想将我的web组件添加到JSP中。我如何连接我的ExtWebComponents来做到这一点?
我的服务器端运行在Servlet容器中。
发布于 2019-11-01 20:20:11
我有一个项目示例,展示了如何做到这一点。客户端是ExtWebComponents,服务器端是Java。
项目备注
JSP示例
<!DOCTYPE HTML>
<html manifest="">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes">
<title>Sandbox Project</title>
<link rel="icon" type="image/x-icon" href="resources/favicon.ico">
<script src="webcomponents-bundle.js"></script>
<link href="ext/ext.css" rel="stylesheet">
</head>
<body>
Testing
<my-sandbox-view></my-sandbox-view>
<%
out.write("<h2>Test jsp<h2>");
%>
<!-- The webpacked resource bundle is imported here -->
<script type="text/javascript" src="ext/ext.js"></script><script type="text/javascript" src="app.js"></script></body>
</html>客户端到服务器端的资源
您必须告诉webpack将资源复制到您的web应用程序目录中,以便它们可以用于您的Java项目。例如,这就是如何使用自定义插件,然后使用webpack手表。
// This causes infinite loop, so I can't use this plugin.
// new CopyWebpackPlugin([{
// from: __dirname + '/build/',
// to: __dirname + '/../sandbox-server/target/test1'
// }]),
// Inline custom plugin - will copy to the target web app folder
// 1. Run npm install fs-extra
// 2. Fix the path, so that it copies to the server's build webapp folder
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
// Debugging
console.log("########-------------->>>>> Finished Ext JS Compile <<<<<------------#######");
let source = __dirname + '/build/';
// TODO Set the path to your webapp build
let destination = __dirname + '/../sandbox-server/target/sandbox';
let options = {
overwrite: true
};
fs.copy(source, destination, options, err => {
if (err) return console.error(err)
console.log('Copy build success!');
})
});
}
}https://stackoverflow.com/questions/58665421
复制相似问题