Jsf Servlet Does not work IntelliJ Idea

1.6k Views Asked by At

I am currently trying to learn java ee basics and there is a simple jsf example project to get learn intelliJ idea as well. Before IntelliJ I was able to develop jsf project with maven in Eclipse and they were working good but when i did the exact same things in the same order (project from webapp archetype, add dependencies to pom, run maven, add jsf servlet to web xml and deploy) I got 404 error in return. Don't know if it arrises from some config must be done in intellij or something independent from intellij.

So here is my code and when i type localhost:8080/faces/index.xhtml either the faces servlet does not get triggered or something else happens so that the xhtml page is not found

1-project structure:

enter image description here

2-web.xml:

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

Most probably these two can explain the issue. Thanks for any help :)

2

There are 2 best solutions below

3
On

I saw this post late, but I hope it helps someone else.

Under Project Structure makes sure you configured JSF:

jsf

2
On

You almost certainly failed to add a web facet and artifact to your project. See the IntelliJ documentation.