我在使用Maven和Eclipse制作我的第一个webproject时遇到了问题...
我是使用maven的新手,我正在努力学习它。我一直在使用Eclipse和Coding Web和Spring项目,但从未使用过maven,所以我想学习它。
我在eclipse中使用原型创建新的maven项目:maven-archetype-webapp然后我更改了我的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>org.springsource.greenbeans.maven</groupId>
<artifactId>WebFlowTemplate</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>WebFlowTemplate Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<build>
<finalName>WebFlowTemplate</finalName>
</build>
</project>
然后我做了一个小的index.jsp来测试:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<title>Spring 3.0 MVC Series</title>
</head>
<body>
<a href="login.jsp">Login</a><p><p>
<a href="hello.html">Say Hello (Spring MVC)</a><p>
<a href="./helloworld">Say Hello (Spring-Web-Flow)</a>
</body>
</html>
但是我在taglib行上遇到错误:
描述资源路径位置类型
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core" input.jsp /WebFlowTemplate/src/main/webapp/WEB-INF/flows/helloworld line 1 JSP Problem
为什么JSP不能找到taglibs?
答案 0 :(得分:3)
jstl的URI应该是:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
有关详细信息,请参阅讨论here。
答案 1 :(得分:1)
您需要将servlet api添加为依赖项并将其标记为已提供。或者查找maven taglib依赖项:
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>