我使用intellij和gradle構建war和tomcat來運行服務器。JSTL不評估c:如果有的話
這裏是我的build.gradle
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:如果或c:當
它只顯示FALSE
我不知道爲什麼它不能正確呈現。
任何幫助?
假設要檢查'$ {true}'你應該將一個變量從你的controller/servlet傳遞到JSP頁面。參考這個例子[post](http://www.java2s.com/Tutorial/Java/0380__JSTL/JSTLIfElseStatement.htm) –
通常你想測試一個變量是否等於某個東西 - 是** test **的名字你的變量? –
另外,你的gradle的相關性是什麼? –