Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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
Java 如何将pom属性放入jsp文件中?_Java_Maven_Jsp_Tomcat_Eclipse Jee - Fatal编程技术网

Java 如何将pom属性放入jsp文件中?

Java 如何将pom属性放入jsp文件中?,java,maven,jsp,tomcat,eclipse-jee,Java,Maven,Jsp,Tomcat,Eclipse Jee,我是一个初学者,我有一个小的多模块maven项目,我用它来玩弄tomcat(8.5)。这个项目的框架来自一个有几年历史的在线课程(它是一个法语平台):https://openclassrooms.com/fr/courses/4503526-organisez-et-packagez-une-application-java-avec-apache-maven)并使用最新版本的Eclipse IDE进行编码 现在我正在开发webapp模块,我的目标是在jsp文件中打印webapp POM中的一些

我是一个初学者,我有一个小的多模块maven项目,我用它来玩弄tomcat(8.5)。这个项目的框架来自一个有几年历史的在线课程(它是一个法语平台):https://openclassrooms.com/fr/courses/4503526-organisez-et-packagez-une-application-java-avec-apache-maven)并使用最新版本的Eclipse IDE进行编码

现在我正在开发webapp模块,我的目标是在jsp文件中打印webapp POM中的一些属性(应用程序的名称、项目版本和时间戳)

为此,我在maven war插件中使用了过滤选项。首先,我将依赖性放在父POM中,如下所示

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>3.1.0</version>
    </plugin>
  </plugins>
</pluginManagement>
然后,我尝试在没有eclipse的情况下执行该操作,因此我使用«mvn clean package»构建了该项目,并使用tomcat的文件管理器部署了.war,但结果是一样的

我试图在这里和互联网上的其他地方找到类似的主题,但我只找到了关于设置POM过滤的老线索(我已经找到了)

总的来说,我真的可以使用外部视角,因为我已经没有解决方案了

谢谢:)

(如有要求,我可以显示整个文件,如POM,但我尽量使其简短,同时从初学者的角度提供所有相关信息)

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <!-- app public name -->
    <application.name>Ticket</application.name>
    <!-- format timestamp -->
    <maven.build.timestamp.format>dd/MM/yyyy</maven.build.timestamp.format>
    <buildTimestamp>${maven.build.timestamp}</buildTimestamp>
</properties>


           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                            <includes>
                                <include>_include/header.jsp</include>
                                <include>_include/footer.jsp</include>
                                <include>about.jsp</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
<body>
<%@ include file="_include/header.jsp"%>

<div class="container">
    <ul>
        <li>Application : ${application.name}</li>
        <li>Version : ${project.version}</li>
        <li>Date du build : ${maven.build.timestamp}</li>
    </ul>
</div>
<%@ include file="_include/footer.jsp"%>
</body>
@WebServlet("/Aboutsrv")
public class Aboutsrv extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public Aboutsrv() {
        super();

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        this.getServletContext().getRequestDispatcher("/WEB-INF/about.jsp").forward(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

    }

}