integration of jsf2.0 and spring 3.1 and hibernate 4.1

故事扮演 提交于 2019-12-13 04:19:59

问题


i want to integrate jsf2.0 and spring 3.1 and hibernate 4.1. but tomcat has error 404:description The requested resource (/jsfspringhiber/page/default.jsf) is not available. what is wrong?

following is my 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_3_0.xsd" version="3.0">

  <display-name>jsfspringhiber</display-name>

  <!-- Add Support for Spring -->
  <listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
  <listener>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
  </listener>

  <!-- Change to "Production" when you are ready to deploy -->
  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>

  <!-- Welcome page -->
  <welcome-file-list>
    <welcome-file>faces/default.xhtml</welcome-file>
  </welcome-file-list>

  <!-- JSF mapping -->
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <!-- Map these files with JSF -->
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

</web-app>

回答1:


I guess your are using eclipse, I think that you have a problem with the deploy.

1) check the tomcat deploy path to see if it is deployed correctly: workspace/.metadata/plugings/org.eclipse.wst.server.core/tmp0/wtpwebapps. (some times help deleting the tmp0, to force tomcat to redeploy).

2) In the project's properties check the deployment assembly and verificy that all the need file are included.

This might work




回答2:


Okay, if you have the url-pattern as /faces/* , the Faces servlet will prepend every request with /faces. So you will have to access the resource as /jsfspringhiber/faces/page/default.xhtml or just /jsfspringhiber (if the welcome file is listed as faces/page/default.xhtml).

Update: Remove all the servlet-mappings and just use one:

<welcome-file-list>
  <welcome-file>default.xhtml</welcome-file>
</welcome-file-list>

<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

and put the default.xhtml file under WebContent directory.

If you really want to map all those url patterns look at this answer




回答3:


i use maven. the correct answer is here. the structure is:



来源:https://stackoverflow.com/questions/11206876/integration-of-jsf2-0-and-spring-3-1-and-hibernate-4-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!