【问题标题】:JSTL is not evaluated with embedded Jetty and the jetty-console-maven-pluginJSTL 不使用嵌入式 Jetty 和 jetty-console-maven-plugin 进行评估
【发布时间】:2012-11-17 21:08:21
【问题描述】:

长话短说:我得到这个作为输出

<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 serverJSTL 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 规范,等等,但它没有帮助。

有人知道出了什么问题吗?

【问题讨论】:

  • 我想知道我是否缺少某些依赖项,例如 servlet 或 JSTL API?我试图在 POM 中添加一些朝那个方向的东西(例如,javax.servlet-api 和 jstl 以及来自 org.glassfish.web 的 jstl-impl,请参阅 stackoverflow.com/questions/6094329/tomcat-7-and-jstl),但这并没有帮助。

标签: java maven jetty jstl


【解决方案1】:

我是 JettyConsole 的创建者,但我未能使用您提供的代码示例重现您描述的问题。

我使用您提供的文件内容重新创建了您的目录结构,运行了干净的 Maven 安装并在生成的 jetty-console 战争上运行了 java -jar。

http://localhost:8080/index.jspx 

按预期呈现,正确解析 JSLT 代码。

http://localhost:8080/

渲染了 403 禁止,可能是因为 index.jspx 不在欢迎文件列表中,而 Jetty 想要隐藏 JSP 源代码。

我想说这个问题应该改进以重现问题,或者关闭。

【讨论】:

  • 有没有关于如何使用 JettyConsole 的文档?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-11-27
  • 2016-02-29
  • 1970-01-01
  • 2011-12-26
  • 2011-05-08
  • 2012-08-25
  • 2015-09-26
相关资源
最近更新 更多