长话短说:我把它作为输出
<html><body><c:if test="false">
strange
</c:if></body></html>
将 JSTL 与嵌入式 Jetty 一起使用时。
长话短说:
我的目录结构:
web-example+
|_src+
| \_main+
| \_webapp+
| |_index.jspx
| |_WEB-INF+
| \_web.xml
\_pom.xml
我的 web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebExample"
version="2.5">
</web-app>
我的 index.jspx:
<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:parts="urn:jsptagdir:/WEB-INF/tags">
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
<html><body>
<c:if test="${'1' == true}">
strange
</c:if>
</body></html>
</jsp:root>
最后,我的 pom.xml:
<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>com.example</groupId>
<artifactId>web-example</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.simplericity.jettyconsole</groupId>
<artifactId>jetty-console-maven-plugin</artifactId>
<version>1.47</version>
<executions>
<execution>
<goals>
<goal>createconsole</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>8.1.4.v20120524</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>8.1.4.v20120524</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>8.1.4.v20120524</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>8.1.4.v20120524</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.1.4.v20120524</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
我认为这是特定于 jetty-console-maven-plugin 的问题,因为当我在 Eclipse 中启动 webapp 时一切正常(使用一个启动 Jetty 的小型 Java 类,我没有在这里包含)。
我查看了其他答案,例如,从无法在嵌入式 Jetty 服务器中加载 JSTL taglib和JSTL 未在嵌入式 Jetty 实例上运行的 JSP 页面中解析,从而改变了一些帮助我到目前为止的事情,例如,我更新了jetty-console-maven-plugin 为了没有旧的 servlet 规范代码,我从 /usr/share/java 中删除了 jsp 和 servlet JAR,我更新了 web.xml 和 index.jspx 的 XML 规范,等等但它没有帮助。
有人知道出了什么问题吗?