问题
I was able to load any xhtml page when I was using JSF and then I thought to add spring. I went to the documentation jsf spring integration and added el-resolver in my faces-config.xml:
<?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_2.xsd"
version="2.2">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
now when I am trying to load the page it's giving the error:
javax.servlet.ServletException: No WebApplicationContext found: no ContextLoaderListener registered? javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
回答1:
You have to add org.springframework.web.context.ContextLoaderListener listener in your WEB-INF\web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
回答2:
The solution was:
- I was not including applicationContext in my WEB-INF folder.
- Spring-asm-3.1.4 was conflicting.
You don't need spring asm if you are using spring version higher than 3.2, as it's included in spring-core. It conflicts with the spring-core and throw other exceptions.
来源:https://stackoverflow.com/questions/27015057/no-webapplicationcontext-found-no-contextloaderlistener-registered