ssh1的各个xml配置和功能说明

hibernet-cfg.xml


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>


<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/survey
</property>
<property name="connection.username">root</property>
<property name="connection.password">java</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">mysql</property>
<mapping resource="com/xasxt/survey/po/Option.hbm.xml" />
<mapping resource="com/xasxt/survey/po/Checker.hbm.xml" />
<mapping resource="com/xasxt/survey/po/Deptmgr.hbm.xml" />
<mapping resource="com/xasxt/survey/po/Customermgr.hbm.xml" />
<mapping resource="com/xasxt/survey/po/Subject.hbm.xml" />
<mapping resource="com/xasxt/survey/po/Paper.hbm.xml" />
<mapping resource="com/xasxt/survey/po/Customer.hbm.xml" />


</session-factory>


</hibernate-configuration>






spring.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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


<bean id="mail" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="defaultEncoding" value="utf-8" />
<!-- 邮件服务器的地址(smtp.163.com) -->
<property name="host" value="192.168.1.23" />
<property name="javaMailProperties">
<props>
<!-- 如果要使用用户名和密码验证,这一步需要 -->
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
<property name="username" value="fulaoshi"/>
<property name="password" value="123"/>
</bean>


   <!--
Spring为和Hibernet整合而提供了一个sessionFactory的实现类
   将Hibernate的SessionFactory注入到Dao中,
   需要在Spring的applicationContext.xml中配置。
   在Spring的配置文件中,
   将hibernate.cfg.xml直接作为属性configLocation的值注入进去
   。因为在org.springframework.orm.hibernate3.LocalSessionFactoryBean
   类中实现了对Hibernate配置文件的注入和解析,
   这里只需要提供一个Hibernate的配置文件即可
   -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="OptionDAO" class="com.xasxt.survey.dao.OptionDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="CheckerDAO" class="com.xasxt.survey.dao.CheckerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="DeptmgrDAO" class="com.xasxt.survey.dao.DeptmgrDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="CustomermgrDAO"
class="com.xasxt.survey.dao.CustomermgrDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="SubjectDAO" class="com.xasxt.survey.dao.SubjectDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="PaperDAO" class="com.xasxt.survey.dao.PaperDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="CustomerDAO" class="com.xasxt.survey.dao.CustomerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>


<!-- 事务配置需注入sessionFactory,因为sessionFactory操作数据库-->
<bean id="tm" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<!-- 目标就是service的实现类 需注入DAO-->
<bean id="RegistbizTarget" class="com.xasxt.biz.RegistImpl">
<property name="customerdao" ref="CustomerDAO"></property>
<property name="customerMgrDAO" ref="CustomermgrDAO"></property>
</bean>
<bean id="employBizTarget" class="com.xasxt.biz.EmployBizImpl">
<property name="checkerDAO" ref="CheckerDAO"></property>
<property name="customerMgrDAO" ref="CustomermgrDAO"></property>
<property name="deptMgrDAO" ref="DeptmgrDAO"></property>
</bean>
<bean id="checkerBizTarget" class="com.xasxt.biz.CheckerBizImpl">
<property name="customerDAO" ref="CustomerDAO"></property>
<property name="sender" ref="mail"></property>
</bean>
<bean id="paperBizTarget" class="com.xasxt.biz.PaperImpl">
<property name="paperDAO" ref="PaperDAO"></property>
<property name="subjectDAO" ref="SubjectDAO"></property>
<property name="optionDAO" ref="OptionDAO"></property>
</bean>
<bean id="customerMgrBizTarget" class="com.xasxt.biz.CustomerMgrBizImpl">
<property name="customermgrDAO" ref="CustomermgrDAO"></property>
<property name="paperDAO" ref="PaperDAO"></property>
</bean>
<bean id="deptMgrBizTarget" class="com.xasxt.biz.DeptMgrBizImpl">
<property name="paperDAO" ref="PaperDAO"></property>
</bean>


<!--代理(AOP)
OpenSessionInViewFilter类作用
假设在你的应用中Hibernate是通过spring来管理它的session.
如果在你的应用中没有使用OpenSessionInViewFilter
或者OpenSessionInViewInterceptor。
session会在transaction结束后关闭。
如果你采用了spring的声明式事务模式,
它会对你的被代理对象的每一个方法进行事务包装(AOP的方式)
。如下:
TransactionProxyFactoryBean的作用是为业务逻辑Bean配置事务代理
1>要注入事务2>代理方式
-->
<bean id="tx-parent" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="tm"></property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED, readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED, readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<!-- 代理  需注入目标-->
<bean id="registbiz" parent="tx-parent" p:target-ref="RegistbizTarget"></bean>
<bean id="employBiz" parent="tx-parent" p:target-ref="employBizTarget"></bean>
<bean id="checkerBiz" parent="tx-parent" p:target-ref="checkerBizTarget"></bean>
<bean id="paperBiz" parent="tx-parent" p:target-ref="paperBizTarget"></bean>
<bean id="customerMgrBiz" parent="tx-parent"p:target-ref="customerMgrBizTarget"></bean>
<bean id="deptMgrBiz" parent="tx-parent" p:target-ref="deptMgrBizTarget"></bean>

<!-- action 中需注入biz 一下name 为struts 中的path="/checker" 名称-->
<bean name="/regist" class="com.xasxt.survey.web.struts.action.RegistAction">
<property name="registbiz" ref="registbiz"></property>
</bean>
<bean name="/employ" class="com.xasxt.survey.web.struts.action.EmployAction">
<property name="employBiz" ref="employBiz"></property>
</bean>
<bean name="/checker" class="com.xasxt.survey.web.struts.action.CheckerAction">
<property name="checkerBiz" ref="checkerBiz"></property>
</bean>
<bean name="/active" class="com.xasxt.survey.web.struts.action.ActiveAction">
<property name="registBiz" ref="registbiz"></property>
</bean>
<bean name="/paper" class="com.xasxt.survey.web.struts.action.PaperAction">
<property name="paperBiz" ref="paperBiz"></property>
</bean>
<bean name="/customerMgr" class="com.xasxt.survey.web.struts.action.CustomerMgrAction">
<property name="customerMgrBiz" ref="customerMgrBiz"></property>
</bean>
<bean name="/deptmgr" class="com.xasxt.survey.web.struts.action.DeptMgrAction">
<property name="deptMgrBiz" ref="deptMgrBiz"></property>
<property name="paperBiz" ref="paperBiz"></property>
</bean>
</beans>




struts-config.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">


<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="customerForm" type="com.xasxt.survey.web.struts.form.CustomerForm" />
  </form-beans>


  <global-exceptions >
   <exception key="" type="java.lang.Exception" path="/sussAnderrMsg.jsp"/>
  </global-exceptions>
  <global-forwards>
   <forward name="global_msg" path="/sussAnderrMsg.jsp"></forward>
  </global-forwards>
  <action-mappings >
    
    <action
      parameter="method"
      path="/employ"
      type="com.xasxt.survey.web.struts.action.EmployAction">
      <set-property property="cancellable" value="true" />
      
      <forward name="login_fail" path="/back/index.jsp" />
      <forward name="checker_login_ok" path="/back/checker/index.jsp" />
      <forward name="admin_login_ok" path="/back/admin/index.jsp" />
      <forward name="findAllEmploy_ok" path="/back/admin/all_admin.jsp" />
      <forward name="refindAllEmploy" path="/employ.do?method=findAllEmploy" redirect="true"></forward>
      <forward name="customerMgr_login_ok" path="/back/customerMgr/index.jsp" />
      <forward name="deptMgr_login_ok" path="/back/deptmgr/index.jsp" />
      
      
    </action>
    <action
      attribute="customerForm"
      name="customerForm"
      parameter="method"
      path="/regist"
      scope="request"
      type="com.xasxt.survey.web.struts.action.RegistAction">
      <set-property property="cancellable" value="true" />
      <forward name="login_fail" path="/front/clientlogin.jsp" />
      <forward name="login_ok" path="/front/client_index.jsp" />
    </action>
    <action
      parameter="method"
      path="/checker"
      type="com.xasxt.survey.web.struts.action.CheckerAction">
      <set-property property="cancellable" value="true" />
      <forward name="findCustomerByState_ok" path="/back/checker/all_customer.jsp" />
    </action>
    <action path="/active" type="com.xasxt.survey.web.struts.action.ActiveAction">
      <set-property property="cancellable" value="true" />
    </action>
    <action
      parameter="method"
      path="/paper"
      type="com.xasxt.survey.web.struts.action.PaperAction">
      <set-property property="cancellable" value="true" />
      <forward name="myPapers_ok" path="/front/paper/myPaper.jsp" />
      <forward name="editPaper_ok" path="/front/paper/editPaper.jsp" />
      <forward name="preview_ok" path="/front/paper/previewPaper.jsp" />
      <forward name="prevote_ok" path="/front/paper/showPaper.jsp" />
      <forward name="voteResult_ok" path="/front/paper/paperResult.jsp" />
      <forward name="preWriteReport_ok" path="/back/customerMgr/writeReport.jsp" />
      
      
    </action>
    <action
      parameter="method"
      path="/customerMgr"
      type="com.xasxt.survey.web.struts.action.CustomerMgrAction">
      <set-property property="cancellable" value="true" />
      
      <forward name="SubjectChartMenu" path="/back/customerMgr/subjectChartMenu.jsp" />
      <forward name="myCustomers_ok" path="/back/customerMgr/myCustomers.jsp" />
      <forward name="findMyPapers_ok" path="/back/customerMgr/showPapers.jsp" />
      
    </action>
    <action
      parameter="method"
      path="/deptmgr"
      type="com.xasxt.survey.web.struts.action.DeptMgrAction">
      <set-property property="cancellable" value="true" />
      <forward name="findReports_ok" path="/back/deptmgr/showPapers.jsp" />
      <forward name="showReport_ok" path="/back/deptmgr/showReport.jsp" />
    </action>
  </action-mappings>


  <!--
  在开发过程中,对于一系列的action处理方法,
  我们如果采用Action作为直接 父类覆盖execute方法处理的话,
  可能会造成Action子类过多,代码结构复杂,配置文件臃肿,
  代码阅读困难等问题,因此对于同一系列的方法,
  我们 一般将其放入DispatchAction的子类中去做,
  这样的有很多优点,也解决了很多问题,
  可是新的问题又来了:
  Spring 的AOP在默认配置情况下是无法切入DispatchAction的方法的,
  因为DispatchAction内部的方法是通过策略设计模式实现的
  (根据 请求利用反射得到方法对象),
  虽然spring AOP的前置拦截能取得真实的类名,
  前后拦截能取得真实的类的方法,
  但是前置拦截和前后拦截是不能合在一个程序段中的这样,
  这样配置,处理请求的Action就能处于Spring的管理之下了
  -->
  <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
  <message-resources parameter="com.xasxt.survey.web.struts.ApplicationResources" />
  <plug-in className="com.xasxt.survey.web.struts.InitPlugIn"></plug-in>
</struts-config>


web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>WEB-INF/spring*.xml</param-value>
</context-param>
<filter>
 <filter-name>encoding</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>
<!--配置Hibernate延迟加载
OpenSessionInViewFilter
过滤器将 Hibernate Session 绑定到请求线程中,
它将自动被 Spring 的事务管理器探测到
假设在你的应用中Hibernate是通过spring来管理它的session.
如果在你的应用中没有使用OpenSessionInViewFilter
或者OpenSessionInViewInterceptor。session会在transaction结束后关闭。
如果你采用了spring的声明式事务模式,
它会对你的被代理对象的每一个方法进行事务包装(AOP的方式)
-->


<filter>
 <filter-name>osiv</filter-name>
 <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
 <filter-name>encoding</filter-name>
 <url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
 <filter-name>osiv</filter-name>
 <url-pattern>*.do</url-pattern>
 <url-pattern>/dwr/*</url-pattern>
 <url-pattern>/chart</url-pattern>
 <url-pattern>/chartLine</url-pattern>
</filter-mapping>
<filter>
<filter-name>hwq</filter-name>
<filter-class>com.xasxt.surver.web.filter.RequestHolderFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hwq</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
 
<!--
上下文监听器
ContextLoaderListener的作用就是启动Web容器时,
自动装配ApplicationContext.xml的配置信息
-->
 <listener>
 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
 
 <servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
 <param-name>config</param-name>
 <param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
 <param-name>debug</param-name>
 <param-value>3</param-value>
</init-param>
<init-param>
 <param-name>detail</param-name>
 <param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
 </servlet>
 <servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
 </servlet-mapping>
 <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
 
 
 <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>
 <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
 <servlet-name>dwr-invoker</servlet-name>
 <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
 
 
 <servlet>
<servlet-name>statisticsPicture</servlet-name>
<servlet-class>com.xasxt.web.servlet.statisticsPicture</servlet-class>
 </servlet>
<servlet-mapping>
<servlet-name>statisticsPicture</servlet-name>
<url-pattern>/chart</url-pattern>
 </servlet-mapping>


<servlet>
<servlet-name>ChartLineServlet</servlet-name>
<servlet-class>com.xasxt.web.servlet.ChartLineServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ChartLineServlet</servlet-name>
<url-pattern>/chartLine</url-pattern>
</servlet-mapping>
 
</web-app>

你可能感兴趣的:(ssh1的各个xml配置和功能说明)