如何解决Maven:在加载index.jsp之前移动文件
我想将文件(例如test.html
)从桌面复制到项目目录(例如jsp-test/web
)。我的项目结构如下:
jsp-test
-web
-WEB-INF
-index.jsp
-jsp-test.iml
-pom.xml
理想情况下,文件结构应为:
jsp-test
-web
-WEB-INF
-index.jsp
-test.html
-jsp-test.iml
-pom.xml
我已经搜索并尝试了一些选项,但是它们似乎没有用。我的pom.xml
看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>jsp-test</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>copy</id>
<phase>compile</phase>
<configuration>
<tasks>
<copy file="/Users/JohnDoe/Desktop/resources/test.html" tofile="/Users/JohnDoe/Desktop/jsp-test/web/test.html"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
我想在编译index.jsp时加载复制的html文件:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
<%@include file="test.html" %>
</head>
<body>
<script> console.log("file load success") </script>
</body>
</html>
提前谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。