【问题标题】:javax.faces.webapp.FacesServlet is not assignable to javax.servlet.Servlet , jakarta.servlet.Servletjavax.faces.webapp.FacesServlet 不能分配给 javax.servlet.Servlet , jakarta.servlet.Servlet
【发布时间】:2021-07-19 10:09:51
【问题描述】:

我尝试在 Intellij 中建立一个 JSF 项目。我注意到 JSF 组件没有被渲染,所以我开始检查post 中列出的内容。这是我的 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"
         xmlns:web = "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 = "WebApp_ID" version="2.5">

    <welcome-file-list>
        <welcome-file>faces/home.xhtml</welcome-file>
    </welcome-file-list>
    <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>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    ...
</web-app>

我的项目可以编译,但 IntelliJ 会突出显示 servlet:

我还在我的 pom.xml 中包含 jsf,以防万一:

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.2.20</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.2.20</version>
    <scope>provided</scope>
</dependency>

知道这里的问题可能是什么吗?

【问题讨论】:

    标签: jsf servlets


    【解决方案1】:

    就我而言,我忘了写:

    extends jakarta.servlet.http.HttpServlet
    

    对于我的.java 文件中的一个类。

    【讨论】:

      猜你喜欢
      • 2015-01-10
      • 1970-01-01
      • 2021-05-31
      • 2021-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多