我的servlets/jsp Web应用程序有一个小问题。我正在尝试在jsp页面中使用jstl。当我使用任何标签时,例如:
<c:out value="${command}"/>
它向我展示了
${command}
我在浏览器中使用的参数'command'值没有生效。我正在使用Maven(我猜问题可能出在这里)。这是pom.xml文件的依赖项:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
我的 web.xml 声明标签:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
以及JSP部分:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Parsing results</title>
<link type="text/css" rel="stylesheet" href="css/page.css"/>
<link type="text/css" rel="stylesheet" href="css/table.css"/>
</head>
<body>
<h2 align="center">Results of
parsing. Parsing method = <c:out value="${command}"/></h2>.......
编辑: 设置命令值的代码很简单:
request.setAttribute("command", parser.getName());
然后是
request.getRequestDispatcher(redir).forward(request, response);
请告诉我,我做错了什么!谢谢!