长话短说:我得到这个作为输出
<html><body><c:if test="false">
strange
</c:if></body></html>
与嵌入式Jetty一起使用JSTL时。
长话长说:
我的目录结构:
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类,我未在此处包括)。
我查看了其他答案(例如,来自cannot load JSTL taglib within embedded Jetty server和JSTL not parsed in a JSP page running on an embedded Jetty instance的答案),从而改变了很多方面,这些都有助于我走得更远,例如,我更新了jetty-console-maven-plugin以便没有旧的servlet。规范代码,我从/ usr / share / java中删除了jsp和servlet JAR,我更新了web.xml和index.jspx的XML规范,依此类推,但是没有帮助。
有人知道出什么问题了吗?
最佳答案
我是JettyConsole的创建者,但无法重现使用提供的代码示例描述的问题。
我使用所提供文件的内容重新创建了目录结构,运行了干净的Maven安装并在产生的jetty-console战争中运行了java -jar。
http://localhost:8080/index.jspx
正确解析JSLT代码后,按预期呈现。
http://localhost:8080/
呈现了403禁止状态,可能是因为index.jspx不在您的欢迎文件列表中,并且Jetty想隐藏JSP源代码。
我想说这个问题应该加以改进以重现该问题,或者关闭。