maven 编译JSP

使用maven2的jetty插件预编译JSP2009-07-17 15:22使用maven2的jetty插件预编译JSP

参考文章
http://docs.codehaus.org/display/JETTY/Maven+Jetty+Jspc+Plugin


pom.xml核心配置文件清单如下:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wgame</groupId>
<artifactId>ln3</artifactId>
<packaging>war</packaging>
<name>ln3</name>
<version>1.0</version>
<build>
<finalName>ln3</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>
${basedir}/web
</webappDirectory>
<warSourceDirectory>
${basedir}/web
</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>prod</id>
<activation>
<property><name>prod</name></property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-jspc-plugin</artifactId>
<version>6.1.16</version>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>jspc</goal>
</goals>
<configuration>
<webAppSourceDirectory>
${basedir}/web
</webAppSourceDirectory>
<generatedClasses>
${basedir}/target/jspc
</generatedClasses>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>
${basedir}/web
</webappDirectory>
<warSourceDirectory>
${basedir}/web
</warSourceDirectory>
<webXml>
${basedir}/web/WEB-INF/web.xml
</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
</dependencies>
</project>

配置了POM.XML后运行命令:
mvn -Dprod package

就将JSP编译好放置在target/jspc目录下了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要在Maven项目中使用JSP,需要在pom.xml文件中添加JSP依赖项。 以下是添加JSP依赖项的步骤: 1. 打开pom.xml文件 2. 在<dependencies></dependencies>标签之间添加以下代码: ``` <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> ``` 3. 保存pom.xml文件 这些依赖项将JSP API和JSTL库添加到项目中。现在就可以在Maven项目中使用JSP了。 ### 回答2: 在Maven中导入JSP库,你需要遵循以下步骤: 1. 打开你的Maven项目,并确保你已经正确配置了pom.xml文件。 2. 在pom.xml文件中,找到`<dependencies>`标签,它位于`<project>`标签内。如果你没有该标签,可以手动添加它。 3. 在`<dependencies>`标签中,添加以下代码,以导入JSP库: ``` <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> ``` 4. 将以上代码添加到`<dependencies>`标签中后,保存pom.xml文件。 5. Maven会自动解析并下载所需的JSP库,这取决于你的互联网连接速度和Maven配置。 6. 一旦下载完成,你就可以在你的Maven项目中使用JSP库了。 请注意,以上代码仅适用于jstl版本1.2,如果你需要不同的版本,你需要相应地更改`<version>`标签的值。 如果你遇到Maven下载依赖项的问题,请确保你的Maven配置正确,并检查你的互联网连接,确保你可以正常访问Maven中央仓库。 ### 回答3: 要在Maven中导入JSP库,你需要在你的项目的pom.xml文件中添加相应的依赖项。首先,打开你的pom.xml文件,并在<dependencies>标签之间添加以下代码: ```xml <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> ``` 这样,你就成功地导入了JSP库。为了实现JSP的功能,我们需要导入两个依赖项。第一个是jstl,它提供了标签库和函数库,可以方便地在JSP页面中使用。第二个是jsp-api,它是JSP的核心API,可以让你在编写JSP页面时使用JSP标记语言和其他相关功能。 注意,对于jsp-api依赖项,我们将<scope>设置为"provided"。这意味着该依赖项应该由你的应用服务器提供,而不是由Maven来管理。大多数JavaEE服务器都会提供jsp-api,因此我们只需要在开发阶段将其包含在编译路径中。 一旦添加了这些依赖项,Maven会自动下载并管理它们的相关库文件。如果你的项目中没有pom.xml文件,你需要创建一个,并将上述代码添加到其中。完成后,保存并重新构建你的项目,就可以开始使用JSP库了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值