我正在尝试合并 jstl
和taglibs
对我的项目的依赖。但是Intellij IDEA
无法识别<c:url value="" />
标签。
这是我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.emusicstore</groupId>
<artifactId>emusicstore</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/javax.servlet.jsp.jstl-api -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
</project>
这是一个链接 href 行,我试图在其中放置 <c:url..>
标签
<title>Carousel Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="<c:url value="/resources/css/bootstrap.min.css" />" rel="stylesheet">
这是屏幕截图。它似乎无法识别 <c:url >
标签和值(在引号中)就像将路径标识为纯文本一样。
什么可能导致此问题以及如何解决此问题?
谢谢。
最佳答案
如果您想在 JSP 页面中使用 c:url
标记(或 core JSTL 标记组中的任何其他标记),则需要包含 JSTL Core 库:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
假设您有以下项目结构:
您可以使用 bootstrap.min.css
文件的相对路径:
<link href="<c:url value="../../resources/css/bootstrap.min.css" />" rel="stylesheet">
或使用您的 contextPath
:
<link href="${pageContext.request.contextPath}/src/main/resources/css/bootstrap.min.css" rel="stylesheet"/>
关于maven - 即使添加依赖项后,Intellij IDEA jSTL 和 taglib 也无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40201005/