2

我有一个项目有一个特殊问题,我在一个项目中同时使用了两个版本的 el-impl jar;我使用 v1.2 来管理我的 jsp 和 2.2 来管理我的 JSF 文件,我想要一个解决方案来共存这两个版本,因为我需要我的 jsp 和我的 jsf 文件

问题是,当我添加 EL 2.2 相关 param-context时,jsp 不起作用,我得到这个异常,因为 jsp 文件不适用于 2.2 版本:

com.sun.faces.config.ConfigurationException: It appears the JSP version of the container is older than 2.1 and unable to locate the EL RI expression factory, com.sun.el.ExpressionFactoryImpl.  If not using JSP or the EL RI, make sure the context initialization parameter, com.sun.faces.expressionFactory, is properly set.

当我删除相关的 EL 2.2 时 param-context,我指的是 web.xml 中的这一部分:

 <context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
  </context-param>

如果删除,则不支持 el-impl2.2,因此当我访问 JSF 文件时,我会收到此异常(因为我不支持 2.2 版本)

    org.apache.el.parser.ParseException: Encountered " "(" "( "" at line 1, column 20.
    Was expecting one of:
        "}" ...
        "." ...
        "[" ...
        ">" ...
        "gt" ...
        "<" ...
        "lt" ...
        ">=" ...
        "ge" ...

    ...


Jul 25, 2012 5:39:24 PM com.sun.faces.lifecycle.ELResolverInitPhaseListener populateFacesELResolverForJsp
INFO: JSF1027: [null] The ELResolvers for JSF were not registered with the JSP container

有人可以帮助我解决将两个 EL jar 都用于同一个项目的解决方案,以允许我通过使用 Maven 的方式与包含 JSP 和 JSF 文件的项目竞争,所以这是我的依赖项的一部分:

<dependency>
      <groupId>org.glassfish.web</groupId>
      <artifactId>el-impl</artifactId>
      <version>2.2</version>
        <scope>provided</scope>
     </dependency> 

      <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency> 
<dependency>
          <groupId>com.sun.faces</groupId>
          <artifactId>jsf-api</artifactId>
          <version>2.1.6</version>
        </dependency>
      <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
          <groupId>com.sun.faces</groupId>
          <artifactId>jsf-impl</artifactId>
          <version>2.1.6</version>
        </dependency>

我的 web.xml 的一部分:

  <?xml version="1.0" encoding="UTF-8"?>
    <web-app 
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">


        <filter>
                <filter-name>springSecurityFilterChain</filter-name>
                <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>

        <filter-mapping>
                <filter-name>springSecurityFilterChain</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
            /WEB-INF/spring-security.xml
            /WEB-INF

    /applicationContext.xml
                </param-value>
            </context-param>


            <context-param>     
            <param-name>com.sun

.faces.expressionFactory</param-name>
        <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>   
    </context-param>

        <!--  to enable Spring MVC we need to add in this web.xml: -->
        <servlet>
            <servlet-name>spring</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>

        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
          </servlet>

        <servlet-mapping>
            <servlet-name>spring</servlet-name>
            <url-pattern>/me/*</url-pattern>
        </servlet-mapping>

        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
            <listener>
            <listener-class>
                org.springframework.web.context.request.RequestContextListener
            </listener-class>
          </listener>

        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.jsf</url-pattern>
          </servlet-mapping>
          <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.faces</url-pattern>
          </servlet-mapping>


        <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
     </servlet-mapping>
    </web-app>

面孔-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

    <!-- JSF and Spring are integrated -->

    <application>
        <el-resolver>
            org.springframework.web.jsf.el.SpringBeanFacesELResolver
        </el-resolver>
    </application>

</faces-config>

我也在使用瓷砖,如果这会导致任何问题,请告诉我,谢谢你帮助我

4

1 回答 1

0

这是绝对不可能的。

但是,您可以在两个单独的项目中运行它们,但直接在项目中包含适当的 EL jar,并从 servlet 容器 lib 文件夹中删除 servlet 容器的预打包 EL jar。这至少允许两个应用程序在相同的 Web 容器、服务器、DNS 名称和端口号上运行。

于 2012-07-25T11:12:22.777 回答