1、Web.xml
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
web-app
id
=
"WebApp_ID"
version
=
"2.4"
xmlns
=
"http://java.sun.com/xml/ns/j2ee"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
=
"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>
<
display-name
>
ss
</
display-name
>
<!-- Use Documents Saved as *.xhtml -->
<
context-param
>
<
param-name
>
javax.faces.DEFAULT_SUFFIX
</
param-name
>
<
param-value
>
.xhtml
</
param-value
>
</
context-param
>
<!-- Special Debug Output for Development -->
<
context-param
>
<
param-name
>
facelets.DEVELOPMENT
</
param-name
>
<
param-value
>
true
</
param-value
>
</
context-param
>
<
context-param
>
<
param-name
>
javax.servlet.jsp.jstl.fmt.localizationContext
</
param-name
>
<
param-value
>
resources.application
</
param-value
>
</
context-param
>
<
context-param
>
<
param-name
>
contextConfigLocation
</
param-name
>
<
param-value
>
/WEB-INF/spring/applicationContext.xml
</
param-value
>
</
context-param
>
<
context-param
>
<
param-name
>
javax.faces.CONFIG_FILES
</
param-name
>
<
param-value
>
/WEB-INF/faces-config/faces-config.xml,/WEB-INF/faces-config/managed-bean.xml
</
param-value
>
</
context-param
>
<
context-param
>
<
param-name
>
javax.faces.STATE_SAVING_METHOD
</
param-name
>
<
param-value
>
client
</
param-value
>
<!--<description>
State saving method: "client" or "server" (= default)
See JSF Specification 2.5.2
</description>-->
</
context-param
>
<
context-param
>
<
param-name
>
org.apache.myfaces.ALLOW_JAVASCRIPT
</
param-name
>
<
param-value
>
true
</
param-value
>
<!--<description>
This parameter tells MyFaces if javascript code should be allowed in the
rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default: "true"
</description>-->
</
context-param
>
<
context-param
>
<
param-name
>
org.apache.myfaces.PRETTY_HTML
</
param-name
>
<
param-value
>
true
</
param-value
>
<!--<description>
If true, rendered HTML code will be formatted, so that it is "human readable".
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default: "true"
</description>-->
</
context-param
>
<
context-param
>
<
param-name
>
org.apache.myfaces.DETECT_JAVASCRIPT
</
param-name
>
<
param-value
>
false
</
param-value
>
</
context-param
>
<
context-param
>
<
param-name
>
org.apache.myfaces.AUTO_SCROLL
</
param-name
>
<
param-value
>
true
</
param-value
>
<!--<description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default: "false"
</description>-->
</
context-param
>
<
context-param
>
<
param-name
>
net.sf.jsfcomp.chartcreator.USE_CHARTLET
</
param-name
>
<
param-value
>
true
</
param-value
>
<
description
>
jfreechart, Charts are either generated by a servlet called chartlet(by default) or a phaselistener
</
description
>
</
context-param
>
<
filter
>
<
filter-name
>
MyFacesExtensionsFilter
</
filter-name
>
<
filter-class
>
org.apache.myfaces.webapp.filter.ExtensionsFilter
</
filter-class
>
<
init-param
>
<
param-name
>
maxFileSize
</
param-name
>
<
param-value
>
20m
</
param-value
>
<!--<description>
Set the size limit for uploaded files. Format: 10 - 10
bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
</description>-->
</
init-param
>
</
filter
>
<
filter-mapping
>
<
filter-name
>
MyFacesExtensionsFilter
</
filter-name
>
<
servlet-name
>
faces
</
servlet-name
>
<
dispatcher
>
REQUEST
</
dispatcher
>
<
dispatcher
>
FORWARD
</
dispatcher
>
</
filter-mapping
>
<
filter-mapping
>
<
filter-name
>
MyFacesExtensionsFilter
</
filter-name
>
<
url-pattern
>
/faces/myFacesExtensionResource/*
</
url-pattern
>
<
dispatcher
>
REQUEST
</
dispatcher
>
<
dispatcher
>
FORWARD
</
dispatcher
>
</
filter-mapping
>
<!-- ajax4jsf -->
<
filter
>
<
display-name
>
Ajax4jsf Filter
</
display-name
>
<
filter-name
>
ajax4jsf
</
filter-name
>
<
filter-class
>
org.ajax4jsf.Filter
</
filter-class
>
</
filter
>
<
filter-mapping
>
<
filter-name
>
ajax4jsf
</
filter-name
>
<
servlet-name
>
faces
</
servlet-name
>
<
dispatcher
>
REQUEST
</
dispatcher
>
<
dispatcher
>
FORWARD
</
dispatcher
>
<
dispatcher
>
INCLUDE
</
dispatcher
>
</
filter-mapping
>
<
listener
>
<!--Listener, that does all the startup work (configuration, init).-->
<
listener-class
>
org.apache.myfaces.webapp.StartupServletContextListener
</
listener-class
>
</
listener
>
<
servlet
>
<
servlet-name
>
SpringContextServlet
</
servlet-name
>
<
servlet-class
>
org.springframework.web.context.ContextLoaderServlet
</
servlet-class
>
<
load-on-startup
>
1
</
load-on-startup
>
</
servlet
>
<
servlet
>
<
servlet-name
>
faces
</
servlet-name
>
<
servlet-class
>
org.apache.myfaces.webapp.MyFacesServlet
</
servlet-class
>
<
load-on-startup
>
1
</
load-on-startup
>
</
servlet
>
<
servlet
>
<
servlet-name
>
Chartlet
</
servlet-name
>
<
servlet-class
>
net.sf.jsfcomp.chartcreator.Chartlet
</
servlet-class
>
</
servlet
>
<
servlet-mapping
>
<
servlet-name
>
faces
</
servlet-name
>
<
url-pattern
>
*.jsf
</
url-pattern
>
</
servlet-mapping
>
<
servlet-mapping
>
<
servlet-name
>
faces
</
servlet-name
>
<
url-pattern
>
*.faces
</
url-pattern
>
</
servlet-mapping
>
<
servlet-mapping
>
<
servlet-name
>
Chartlet
</
servlet-name
>
<
url-pattern
>
*.chart
</
url-pattern
>
</
servlet-mapping
>
<
welcome-file-list
>
<
welcome-file
>
index.html
</
welcome-file
>
<
welcome-file
>
index.htm
</
welcome-file
>
<
welcome-file
>
index.jsp
</
welcome-file
>
<
welcome-file
>
default.html
</
welcome-file
>
<
welcome-file
>
default.htm
</
welcome-file
>
<
welcome-file
>
default.jsp
</
welcome-file
>
</
welcome-file-list
>
<
jsp-config
>
<
taglib
>
<
taglib-location
>
/WEB-INF/tlds/chartcreator.tld
</
taglib-location
>
<
taglib-uri
>
http://sourceforge.net/projects/jsf-comp
</
taglib-uri
>
</
taglib
>
<
taglib
>
<
taglib-location
>
/WEB-INF/tlds/arcmind.tld
</
taglib-location
>
<
taglib-uri
>
http://arcmind.com/jsf/component/tags
</
taglib-uri
>
</
taglib
>
</
jsp-config
>
</
web-app
>
2、applicationContext.xml
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
beans
xmlns
=
"http://www.springframework.org/schema/beans"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop
=
"http://www.springframework.org/schema/aop"
xmlns:tx
=
"http://www.springframework.org/schema/tx"
xsi:schemaLocation
=
"
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
>
<
bean
class
=
"org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"
/>
<
bean
class
=
"org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>
<
bean
id
=
"entityManagerFactory"
class
=
"org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
>
<
property
name
=
"dataSource"
ref
=
"dataSource"
/>
<
property
name
=
"persistenceUnitName"
value
=
"my"
/>
<
property
name
=
"loadTimeWeaver"
>
<
bean
class
=
"org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"
/>
</
property
>
<
property
name
=
"jpaVendorAdapter"
>
<
bean
class
=
"org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
>
<
property
name
=
"database"
value
=
"MYSQL"
/>
<
property
name
=
"showSql"
value
=
"true"
/>
</
bean
>
</
property
>
</
bean
>
<
bean
id
=
"dataSource"
class
=
"org.springframework.jdbc.datasource.DriverManagerDataSource"
>
<
property
name
=
"driverClassName"
value
=
"com.mysql.jdbc.Driver"
/>
<
property
name
=
"url"
value
=
"jdbc:mysql://localhost/my?useUnicode=true&characterEncoding=utf8"
/>
<
property
name
=
"username"
value
=
"my"
/>
<
property
name
=
"password"
value
=
"my"
/>
</
bean
>
<
bean
id
=
"transactionManager"
class
=
"org.springframework.orm.jpa.JpaTransactionManager"
>
<
property
name
=
"entityManagerFactory"
ref
=
"entityManagerFactory"
/>
</
bean
>
<
tx:annotation-driven
transaction-manager
=
"transactionManager"
/>
<!---->
<!--
<bean id="personService" class="service.PersonServiceImpl" />
<bean id="ResourceService" class="my.service.ResourceServiceImpl" />
<bean id="personAction" scope="prototype"
class="action.PersonAction">
<constructor-arg ref="personService" />
</bean> -->
</
beans
>
3、persistence.xml
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
persistence
xmlns
=
"http://java.sun.com/xml/ns/persistence"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
=
"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version
=
"1.0"
>
<
persistence-unit
name
=
"my"
transaction-type
=
"RESOURCE_LOCAL"
>
<
provider
>
org.hibernate.ejb.HibernatePersistence
</
provider
>
<!--
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.username" value="my"/>
<property name="hibernate.connection.password" value="my"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/my?useUnicode=true&characterEncoding=utf8"/>
<property name="hibernate.max_fetch_depth" value="3"/>
</properties>-->
</
persistence-unit
>
</
persistence
>
4、faces-config.xml
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<!
DOCTYPE
faces-config
PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd"
>
<!-- =========== FULL CONFIGURATION FILE ================================== -->
<
faces-config
>
<
application
>
<
message-bundle
>
resources.application
</
message-bundle
>
<
locale-config
>
<
default-locale
>
en
</
default-locale
>
</
locale-config
>
<
view-handler
>
com.sun.facelets.FaceletViewHandler
</
view-handler
>
</
application
>
<
component
>
<!-- LIFECYCLE -->
<
lifecycle
>
<
phase-listener
>
com.sterning.jsf.ajax.AjaxListener
</
phase-listener
>
</
lifecycle
>
</
faces-config
>