Struts2+spring2+hibernate3整合方案(2)
applicationContext-dao.xml内容:
<?xml?version="1.0"?encoding="UTF-8"?>
applicationContext-service.xml内容:
?
<?xml?version="1.0"?encoding="UTF-8"?>
action-servlet.xml内容:
?
<?xml?version="1.0"?encoding="UTF-8"?>
以上几个xml文件的内容暂且不要理会,继续往下看,你就自动明白的,不用我解释。
4)日志部分:log4j.properties 、commons-logging.properties
log4j.properties内容:
?
#?For?JBoss:?Avoid?to?setup?Log4J?outside?$JBOSS_HOME/server/default/deploy/log4j.xml!commons-logging.properties
内容:
5)web.xml
?
<?xml?version="1.0"?encoding="UTF-8"?>
<web-app?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"?
?version="2.4">
?<display-name>firstssh</display-name>
?<description>this?is?a?simple?example</description>
?<context-param>
??<param-name>webAppRootKey</param-name>
??<param-value>firstssh.root</param-value>
?</context-param>
?
?<context-param>
??<param-name>contextConfigLocation</param-name>
??<param-value>/WEB-INF/applicationContext-*.xml,/WEB-INF/action-servlet.xml</param-value>
?</context-param>
?<context-param>
??<param-name>log4jConfigLocation</param-name>
??<param-value>/WEB-INF/log4j.properties</param-value>
?</context-param>
?<listener>
??<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
?</listener>
?<!--?用于初始化Spring容器的Listener?-->
????<listener>
????????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
????</listener>
?
?
?<!--?定义整合SiteMesh必须的ActionContextCleanUp?Filter?
?<filter>
??<filter-name>struts-cleanup</filter-name>
??<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
?</filter>-->
?<!--?定义Struts2的FilterDispathcer的Filter?-->
????<filter>
????????<filter-name>struts2</filter-name>
????????<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
????</filter>
???<!--???<filter-mapping>
????????<filter-name>struts-cleanup</filter-name>
????????<url-pattern>/*</url-pattern>
????</filter-mapping>-->
?<!--?FilterDispatcher用来初始化struts2并且处理所有的WEB请求。?-->
????<filter-mapping>
????????<filter-name>struts2</filter-name>
????????<url-pattern>/*</url-pattern>
????</filter-mapping>
????
???<!--?这是一个产生验证码的servlet?-->
????<servlet>
????????<servlet-name>img</servlet-name>
????????<servlet-class>com.firstssh.servlet.AuthImg</servlet-class>
????</servlet>
??
????<servlet-mapping>
????????<servlet-name>img</servlet-name>
?????<url-pattern>/authImg</url-pattern>
????</servlet-mapping>
????<filter>???
????????<filter-name>encodingFilter</filter-name>???
????????<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>???
????????<init-param>???
????????????<param-name>encoding</param-name>???
????????????<param-value>utf-8</param-value>???
????????</init-param>???
????</filter>???
????<filter-mapping>???
????????<filter-name>encodingFilter</filter-name>???
????????<url-pattern>*.action</url-pattern>???
????</filter-mapping>???
????<filter-mapping>???
????????<filter-name>encodingFilter</filter-name>???
????????<url-pattern>*.jsp</url-pattern>???
????</filter-mapping>
????<filter>???
????????<filter-name>hibernateFilter</filter-name>???
????????<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>???
????</filter>?
????<filter-mapping>???
????????<filter-name>hibernateFilter</filter-name>???
????????<url-pattern>*.action</url-pattern>???
????</filter-mapping>?
????
????<!--?DWR?Servlet-->
??<servlet>
????<servlet-name>dwr-invoker</servlet-name>
????<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
????<init-param>
??????<param-name>debug</param-name>
??????<param-value>true</param-value>
????</init-param>
??</servlet>
??<servlet-mapping>
????<servlet-name>dwr-invoker</servlet-name>
????<url-pattern>/dwr/*</url-pattern>
??</servlet-mapping>
??
????<session-config>???
????????<session-timeout>10</session-timeout>???
????</session-config>?
????
??<welcome-file-list>
????<welcome-file>index.jsp</welcome-file>
??</welcome-file-list>
??<error-page>
????<error-code>401</error-code>
????<location>/401.htm</location>
??</error-page>
??<error-page>
????<error-code>403</error-code>
????<location>/403.htm</location>
??</error-page>
??<error-page>
????<error-code>404</error-code>
????<location>/404.htm</location>
??</error-page>
??<error-page>
????<error-code>500</error-code>
????<location>/500.htm</location>
??</error-page>
</web-app>
?
6)dwr.xml