带有Tomcat的JSF WebApp(哪个版本?) [英] JSF WebApp with Tomcat (which version?)

查看:143
本文介绍了带有Tomcat的JSF WebApp(哪个版本?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个JSF 2 Web应用程序,但是对于设置环境文件(即web.xml和faces-config.xml)感到困惑

I want to develop a JSF 2 web application, but I'm confused about setting up the environment files, i.e. web.xml and faces-config.xml

我想使用JSF 2(.xhtml),Tomcat 9.0和Open JDK 11.0.2

I would like to use JSF 2 (.xhtml), Tomcat 9.0 and Open JDK 11.0.2

我看过以下页面: http://tomcat.apache.org/whichversion.html但我不清楚各列的确切含义,尤其是(对于Tomcat 9.0.31行)

I have seen this page: http://tomcat.apache.org/whichversion.html but I am not clear on the exact meaning of the columns, in particular (for the Tomcat 9.0.31 row)

Servlet Spec 4.0:这是否意味着我必须在web.xml文件中设置web-app version ="4.0"? JSP Spec 2.3:我应该设置什么? EL 3.0规范:这是否意味着我必须在faces-config.xml文件中设置faces-config version ="3.0"?

Servlet Spec 4.0: does it mean I have to set web-app version = "4.0" in the web.xml file? JSP Spec 2.3: what should I set? EL 3.0 specification: does that mean I have to set faces-config version = "3.0" in the faces-config.xml file?

谢谢!

推荐答案

Servlet Spec 4.0:这是否意味着我必须将web-app version设置为"4.0",在web.xml文件中?

是的

JSP Spec 2.3:我应该设置什么?

什么都没有. JSP版本与Servlet版本并驾齐驱.因此4.0web.xml可以激活JSP 2.3.

Nothing. JSP version goes hand in hand with Servlet version. So web.xml of 4.0 is fine to activate JSP 2.3.

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0"
>
    <!-- Config here. -->
</web-app>

EL 3.0规范:这是否意味着我必须设置faces-config版本="3.0",在faces-config.xml文件中?

绝对不是. EL不是JSF. EL版本也与Servlet版本并驾齐驱.因此4.0web.xml可以激活EL 3.0.

Absolutely not. EL is not JSF. EL version also goes hand in hand with Servlet version. So web.xml of 4.0 is fine to activate EL 3.0.

faces-config.xml版本表示JSF版本.但是Tomcat完全不提供JSF.您必须手动安装.当前可用的最新JSF版本是2.3,因此您必须将faces-config.xml设置为2.3.

The faces-config.xml version indicates JSF version. But Tomcat does not ship with JSF out the box at all. You have to install it manually. Currently available latest JSF version is 2.3, so you have to set faces-config.xml to 2.3.

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
    version="2.3"
>
    <!-- Config here. -->
</faces-config>

请注意,Tomcat也未随JSTL和CDI一起提供,而JSF也需要它们.因此,您还必须手动安装它们.或者,更好的是,选择一个普通的JEE服务器,而不是准系统的servlet容器.然后,您无需手动安装目标servlet容器不支持的单个JEE工件.

Note that Tomcat also doesn't ship with JSTL and CDI out the box while they are also required by JSF. So you also have to manually install them both. Or, better, just pick a normal JEE server instead of a barebones servletcontainer. Then you don't need to manually install individual JEE artifacts not supported by the target servletcontainer.

  • How to properly install and configure JSF libraries via Maven?
  • How to install and use CDI on Tomcat?
  • What exactly is Java EE?

这篇关于带有Tomcat的JSF WebApp(哪个版本?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆