JSF2整合Spring3------JSF学习笔记4

前言:

除了JSF的配置文件 faces-config.xml 添加一些额外的代码外,没有其他特殊的

1.web.xml  核心代码

 <!-- Spring -->
 <listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>


<!-- JSF config Start -->
<context-param> 
	<param-name>javax.faces.STATE_SAVING_METHOD</param-name> 
	<param-value>client</param-value> 
</context-param>

<context-param> 
	<param-name>javax.faces.PROJECT_STAGE</param-name> 
	<param-value>Development</param-value> 
</context-param>

<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>
<!-- JSF config End -->

 

2.JSF配置文件  faces-config.xml

<!-- 整合Spring   除此处外, 其他都是jsf的一般配置-->
<application> 
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> 
</application> 


<navigation-rule>
	<from-view-id>/logon/logon.jsp</from-view-id>
	<navigation-case>
		<from-action>#{user.logonValidate }</from-action>
		<from-outcome>logonSuccess</from-outcome>	<!-- 对应bean文件内logonValidate方法d返回值 -->
		<to-view-id>/logon/logonSuccess.jsp</to-view-id>
	</navigation-case>
	
	<navigation-case>
		<from-action>#{user.logonValidate }</from-action>
		<from-outcome>logonFailure</from-outcome>	<!-- 对应bean文件内logonValidate方法d返回值 -->
		<to-view-id>/logon/logon.jsp</to-view-id>
	</navigation-case>
</navigation-rule>

 

3.spring配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
	
	<!-- jsf的bean -->
	<bean id="user" class="logon.UserBean" > 
		<property name="logonService" ref="logonService" /> 
	</bean>
	
	<bean id="logonService" class="logon.LogonService" > 
		<property name="logonDao" ref="logonDao" /> 
	</bean>
	
	<bean id="logonDao" class="logon.LogonDao" > </bean>

</beans>

 

4.其他文件 略;附件是完整的代码

 

 

你可能感兴趣的:(Spring3)