【问题标题】:Using both EL 1.2 and 2.2 syntax (el-api-2.2.) in the same project (to coexist JSP working with 1.2 and JSF working with 2.2)在同一个项目中同时使用 EL 1.2 和 2.2 语法 (el-api-2.2.)(与 1.2 一起工作的 JSP 和与 2.2 一起工作的 JSF 共存)
【发布时间】:2012-07-23 10:17:08
【问题描述】:

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

问题是,当我添加与param-context 相关的 EL 2.2 时,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.

当我删除与param-context 相关的EL 2.2 时,我指的是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 都用于同一个项目的解决方案,以允许我与包含 JSP 和 JSF 文件的项目竞争,顺便说一下我使用 Maven 的方式,所以这是我的依赖项的一部分:

<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>

faces-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>

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

【问题讨论】:

    标签: spring jsf jakarta-ee maven el


    【解决方案1】:

    这是绝对不可能的。

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

    【讨论】:

      猜你喜欢
      • 2011-01-20
      • 2013-10-31
      • 1970-01-01
      • 2015-09-20
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      • 2016-05-24
      • 1970-01-01
      相关资源
      最近更新 更多