A JSF web application can be easily integrated with Spring by loading a Spring context file within web.xml
(through a context loader listener). Since JSF 1.2, Spring's SpringBeanFacesELResolver
object reads Spring beans as JSF managed beans. JSF only deals with the presentation tier and has a controller named FacesServlet
. All we need to do is register FacesServlet
in the application deployment descriptor or web.xml
(in this section, we use JavaConfig to register it) and map any request with the desired extension (.xhtml
here) to go through FacesServlet
.
First, we should include the JSF API and its implementation in the project dependencies:
<properties> <spring-framework-version>4.1.6.RELEASE</spring-framework-version> <mojarra-version>2.2.12</mojarra-version> </properties> ... <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>${mojarra-version...