【发布时间】:2020-02-14 09:55:30
【问题描述】:
JSP 页面:
<%@ page language="java" contentType="text/html; utf-8"
pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="sv" dir="ltr">
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<c:forEach begin="1" end="5" var="current">
<c:out value="${current}"/>
<p>${current}</p>
</c:forEach>
</body>
</html>
Maven POM 文件:
<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>GroupName</groupId>
<artifactId>AppName</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>Whatever</finalName>
</build>
</project>
而不是输出 1 2 3 4 5 我得到 ${current} ${current} ${current} ${current} ${current}
我在 Eclipse 中编写代码,并使用 maven 进行依赖。我在本地 Tomcat 服务器中运行代码。 可能是很少的背景信息,但它很难,因为 Eclipse + Tomcat + Maven = 100000 种做事方式,奇怪的怪癖,配置等。希望它可能是显而易见的。
【问题讨论】: