Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未呈现Spring启动${}标记_Java_Spring_Spring Mvc_Spring Boot - Fatal编程技术网

Java 未呈现Spring启动${}标记

Java 未呈现Spring启动${}标记,java,spring,spring-mvc,spring-boot,Java,Spring,Spring Mvc,Spring Boot,我有一个简单的Spring Boot MVC应用程序,但似乎无法在视图中呈现${}标记 根据研究,我已经在POM.XML文件中添加了以下依赖项,但这没有帮助 <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <

我有一个简单的Spring Boot MVC应用程序,但似乎无法在视图中呈现${}标记

根据研究,我已经在POM.XML文件中添加了以下依赖项,但这没有帮助

<dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
以下是我的看法:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="template" tagdir="/WEB-INF/tags/template" %>

<template:login metaTitle="Intranet Login">
    <h1>Please login</h1>
    <h2>${name}</h2>
</template:login>

请登录
${name}
模板标签

<%@ tag body-content="scriptless" dynamic-attributes="dynamicAttributes" trimDirectiveWhitespaces="true" %>
<%@ attribute name="metaTitle" type="java.lang.String" rtexprvalue="true" required="true" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>${metaTitle}</title>
</head>

<body>
    <jsp:doBody />
</body>

</html>

${metaTitle}

我正在将此项目作为war文件部署到Apache TomCat。

您的模板标记在做什么……您是否希望呈现它们或应用EL?您是否意外地有一个web.xml?是的,它看起来像是IntelliJ在创建项目时创建的。我已经删除了它,问题解决了。我还发现了这个链接,它描述了一个类似的问题,如果你的web.xml版本太旧(2.4或更低版本)EL不起作用。你的模板标记在做什么…你想让它们呈现还是应用EL?你是否意外地有一个web.xml?是的,它看起来像是IntelliJ在我创建项目时创建的。我已经删除了它,问题解决了。我还发现了这个链接,它描述了一个类似的问题,如果您的web.xml版本太旧(2.4或更早版本),EL无法工作。
<%@ tag body-content="scriptless" dynamic-attributes="dynamicAttributes" trimDirectiveWhitespaces="true" %>
<%@ attribute name="metaTitle" type="java.lang.String" rtexprvalue="true" required="true" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>${metaTitle}</title>
</head>

<body>
    <jsp:doBody />
</body>

</html>