1. Add the following code to pom. xml:
<! -- Begin-precompiling jsps -->
<Plugin>
<GroupId> org. codehaus. mojo </groupId>
<ArtifactId> jspc-maven-plugin </artifactId>
<Configuration>
<InjectString> & lt ;! -- [Insert fragment here] -- & gt; </injectString>
<InputWebXml >$ {basedir}/WebContent/WEB-INF/web. xml </inputWebXml>
<OutputWebXml >$ {basedir}/target/jspweb. xml </outputWebXml>
<WarSourceDirectory >$ {basedir}/WebContent </warSourceDirectory>
<Verbose> true </verbose>
<Filtering> true </filtering>
<Directory >$ {basedir}/WebContent </directory>
<Shortdes>
<Include> **/*. jsp </include>
</Shortdes>
</Configuration>
<Executions>
<Execution>
<Id> jspc </id>
<Goals>
<Goal> compile </goal>
</Goals>
</Execution>
</Executions>
</Plugin>
<Plugin>
<GroupId> org. apache. maven. plugins </groupId>
<ArtifactId> maven-war-plugin </artifactId>
<Configuration>
<WebXml >$ {basedir}/WebContent/WEB-INF/web. xml </webXml>
</Configuration>
</Plugin>
<! -- End-precompiling jsps -->
---------------------------------------------------------------
Description: www.2cto. com1: <injectString> & lt ;! -- [Insert fragment here] -- & gt; </injectString>
Search for the string consistent with the preceding configuration in the web. xml file and insert the pre-compiled servlet code (these are automatically generated ).
NOTE 2: <inputWebXml >$ {basedir}/WebContent/WEB-INF/web. xml </inputWebXml>
<OutputWebXml >$ {basedir}/target/jspweb. xml </outputWebXml>
The web. xml Path of the inputWebXml configuration item, and the web. xml storage path after the precompiled code is inserted in the outputWebXml configuration item.
NOTE 3: <warSourceDirectory >$ {basedir}/WebContent </warSourceDirectory>
Configure which path to pre-compile the JSP file
Note 4:
<Plugin>
<GroupId> org. apache. maven. plugins </groupId>
<ArtifactId> maven-war-plugin </artifactId>
<Configuration>
<WebXml >$ {basedir}/WebContent/WEB-INF/web. xml </webXml>
</Configuration>
</Plugin>
Configure Maven to create a war package
----------------------------------------------------------
2. Add the following content to the web. xml file:
<! -- [Insert fragment here] -->
----------------------------------------------------------
Note: insert pre-compiled code. (Some servlet configuration codes are automatically generated)