maven2预编译JSP
4252 点击·0 回帖
![]() | ![]() | |
![]() | 1. 在pom.xml中加入以下代码: <!-- begin - precompiling jsps --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jspc-maven-plugin</artifactId> <configuration> <injectString><!-- [INSERT FRAGMENT HERE] --></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> <includes> <include>**/*.jsp</include> </includes> </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 --> --------------------------------------------------------------- 说明点www.atcpu.com1:<injectString><!-- [INSERT FRAGMENT HERE] --></injectString> 到web.xml文件中去寻找与上面的配置一致的字符串,作为插入“预编译”的servlet的代码(这些是自动生成的)。 说明点2:<inputWebXml>${basedir}/WebContent/WEB-INF/web.xml</inputWebXml> <outputWebXml>${basedir}/target/jspweb.xml</outputWebXml> inputWebXml 配置项目的web.xml路径,outputWebXml配置插入预编译代码后的web.xml存放路径。 说明点3:<warSourceDirectory>${basedir}/WebContent</warSourceDirectory> 配置对哪个路径JSP文件进行预编译 说明点4: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webXml>${basedir}/WebContent/WEB-INF/web.xml</webXml> </configuration> </plugin> 配置Maven 打war包 ---------------------------------------------------------- 2. 在web.xml文件中加入 <!-- [INSERT FRAGMENT HERE] --> ---------------------------------------------------------- 说明:插入预编译的代码。(这是一些servlet的配置代码,是自动生成的) | |
![]() | ![]() |