【问题标题】:Library missing for jsp:includejsp:include 缺少库
【发布时间】:2012-03-09 18:59:37
【问题描述】:

我正在使用 xmlns:jsp="http://java.sun.com/jsp/page" 在我的 xhtml 面孔页面中声明 jsp 命名空间

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:jsp="http://java.sun.com/jsp/page"
      xml:lang="en" lang="en">

但是 jsp:include 指令没有被处理,只是被渲染。我的 IDE (Netbeans) 告诉我它找不到此命名空间的库。我将 maven 与以下 pom.xml 文件一起使用。我有另一个应用程序部署到同一个容器中,它使用类似的结构,但没有使用 maven。我无法弄清楚我需要包含什么库才能使任何 jsp:directives 正常工作。

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.j2anywhere.demo</groupId>
<artifactId>JSFDebug</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>

<name>JSFDebug</name>
<url>http://maven.apache.org</url>

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.1.7</version>            
        <scope>runtime</scope>
    </dependency>    
    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>jstl-api</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>jstl-impl</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency> 
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>            
    </plugins>
</build>
<properties>
    <netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
</properties>

提前致谢

【问题讨论】:

    标签: java jsp jsf


    【解决方案1】:

    您正在使用 Facelets,它基本上是 JSP 的继承者。这是两种完全不同的视图技术。一种是基于 XML 的,另一种是基于 Servlet 的。 Facelets中不能使用JSP标签,JSP中也不能使用Facelets标签。

    您需要改用 Facelets 自己的&lt;ui:include&gt;

    <ui:include src="/WEB-INF/includes/foo.xhtml" />
    

    在使用 Facelets 进行开发时完全忘记 JSP。

    另见:

    【讨论】:

    • 我同意你的观点,但我有另一个应用程序使用几乎相同的库和页面设置工作。这就是让我困惑的地方。
    • 显然是 JSP 页面而不是 Facelets 页面,或者它是实际上 &lt;ui:include&gt;
    • 显然我错了。它也不能在其他应用程序中工作。奇怪的是,有些事情在凌晨 03:00 是完全有意义的,然后当你醒来时又完全没有意义。感谢您的帮助。
    猜你喜欢
    • 2012-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2011-04-22
    • 2017-04-20
    • 2013-02-07
    相关资源
    最近更新 更多