Jsp JSTL没有评估c:如果有

Jsp JSTL没有评估c:如果有,jsp,gradle,jstl,Jsp,Gradle,Jstl,我使用intellij和gradle构建war,使用tomcat运行服务器 这是我的身材,格雷德尔 apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'war' import org.apache.tools.ant.filters.ReplaceTokens compileJava { sourceCompatibility = 1.8 targetCompatibility = 1.8 } eclips

我使用intellij和gradle构建war,使用tomcat运行服务器

这是我的身材,格雷德尔

apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'war'

import org.apache.tools.ant.filters.ReplaceTokens

compileJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

eclipse.classpath.downloadSources = true
eclipse.classpath.downloadJavadoc = true

war.archiveName "paths.war"
repositories {
    maven { url 'https://repo.maven.apache.org/maven2/' }
    flatDir(dirs: 'dep-lib')
}

dependencies {
    providedCompile 'javax.servlet:javax.servlet-api:3.1.+'
    providedCompile 'javax.servlet.jsp:javax.servlet.jsp-api:2.3.+'

    // explicit, so that we don't get the jar file in the project
    compile 'log4j:log4j:1.2.+'

    compile 'org.apache.commons:commons-lang3:3.+'
    compile 'commons-validator:commons-validator:1.4.+'


    compile 'javax.servlet:jstl:1.2'
    compile 'org.json:json:20140107'

    testCompile 'junit:junit:5.+'
    testCompile 'commons-io:commons-io:2.4'
    testCompile group: 'org.springframework', name: 'spring-core', version: '4.2.6.RELEASE'
    testCompile group: 'org.springframework', name: 'spring-test', version: '4.2.6.RELEASE'
}

task versionWebXml(type: Copy) {
    println("Copy")
    from('src/main/webapp/WEB-INF/') {
        filter(ReplaceTokens, tokens: project.ext.properties)
        include 'web.xml'
    }
    println("${buildDir}")
    into "${buildDir}"
}

war {
    println("WAR")
    webInf {
        setDuplicatesStrategy "EXCLUDE"
    }
    webXml = file("${buildDir}/web.xml")
}


task devDeploy(type: Copy) {
    if (file("dev.properties").exists()) {
        ext.devProps = new Properties()
        devProps.load(new FileInputStream("dev.properties"))
        from war.archivePath
        into devProps['deployDir'] + "/webapps/"
    }
}

war.dependsOn versionWebXml
war.dependsOn test
devDeploy.dependsOn war
我有以下代码

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<body>
    <c:set var="solution" value="${path}"/>
    <% System.out.println(PageContext.REQUEST); %>

    <c:if test="${true}">
        IF TRUE
    </c:if>
    <c:choose>
        <c:when test="${true}">
            TRUE
        </c:when>
        <c:otherwise>
           FALSE
        </c:otherwise>
    </c:choose>
</body>

如果是真的
符合事实的
错误的
呈现时,该页不计算任何c:if或c:when

它只显示FALSE

我不知道为什么渲染不正确


有什么帮助吗?

您可以删除代码:


假设不检查
${true}
而应该将一个变量从控制器/servlet传递到JSP页面。参考这个例子,通常你想测试一个变量是否等于某个东西-测试的是你变量的名称吗?还有,你的梯度的相关性是什么?我知道你通常在c中测试什么:但是,如果这是一个测试例子,表明它甚至没有评估它。除非我弄错了,${true}不会导致c:if计算true吗?至于gradle,这表明我包括了JSTL库。这会有什么帮助?@John Hamlett IV:我在使用JSTL时遇到了类似的问题,但我也没有得到任何帮助。当我删除内容时,它运行正常。我不知道确切的原因,但我希望它能对你有用。“这对你有效吗?”约翰·哈姆雷特四世,我再次看到了你的问题,我想我误解了你的困惑,你不在里面,或者太不在里面,对不起,忘了我的答案。