SSH三大框架的配置文件笔记

Tomcat配置文件web.xml

<servlet>

       <servlet-name>actionservlet-name>

    <servlet-class>org.apache.struts.action.ActionServletservlet-class>

       <init-param>

           <param-name>configparam-name>

           <param-value>/WEB-INF/struts-config.xmlparam-value>

       init-param>

       <init-param>

           <param-name>debugparam-name>

           <param-value>3param-value>

       init-param>

       <init-param>

           <param-name>detailparam-name>

           <param-value>3param-value>

       init-param>

       <load-on-startup>0load-on-startup>

    servlet>

    <servlet-mapping>

       <servlet-name>actionservlet-name>

       <url-pattern>*.dourl-pattern>

    servlet-mapping>

    <welcome-file-list>

       <welcome-file>login.jspwelcome-file>

    welcome-file-list>

  

    <context-param>

       <param-name>contextConfigLocationparam-name>

       <param-value>classpath:applicationContext-*.xmlparam-value>

    context-param>

 

    <listener>

       <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>

    listener>

web-app>


struts文件配置struts-config.xml

<form-beans>

<form-bean name="loginForm" type="com.bjpower.usermar.action.LoginForm"/>

form-beans>

 

<action-mappings>

<action path="/login" type="org.springframework.web.struts.DelegatingActionProxy"name="loginForm" scope="request">

forward name="success"  path="/login.success.jsp"/>

action>

action-mappings>

 Spring配置文件applicationContext.xml

<bean id="addUser"class="com.bjpower.hibernate.AddUserImp">

<property name="addLog" ref="addLog"/>

<property name="sessionFactory" ref="sessionFactory" />

bean>

<bean id="addLog" class="com.bjpower.hibernate.AddLogImp">

<property name="sessionFactory" ref="sessionFactory" />

bean>

  

<bean id="sessionFactory"

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="configLocation">

<value>classpath:hibernate.cfg.xmlvalue>

property>

bean>

<bean id="transactionManager"

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<property name="sessionFactory" ref="sessionFactory" />

bean>

  

<aop:config>

      <aop:pointcut expression="execution(*add*(..))" id="addMethod"/>

      <aop:advisor advice-ref="txadvice"pointcut-ref="transactionManager" />

aop:config>

  

<tx:advice id="txadvice" transaction-manager="transactionManager">

      <tx:attributes>

        <tx:method name="add*"propagation="REQUIRED" />

        <tx:method name="del*"propagation="REQUIRED" />

        <tx:method name="*"propagation="REQUIRED" read-only="false"/>

tx:attributes>   tx:advice>     beans>


Hibernate配置文件hibernate.cfg.xml

<hibernate-configuration>

   <session-factory>

      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driverproperty>

      <property name="hibernate.connection.username">rootproperty>

      <property name="hibernate.connection.password">rootproperty>

      <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/SpringTractionproperty>

      <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialectproperty>

      <property name="show_sql">trueproperty>

      <property name="current_session_context_class">threadproperty>

      <mapping resource="com/bjpower/hibernate/Log.hbm.xml"/>

      <mapping resource="com/bjpower/hibernate/User.hbm.xml" />

   session-factory>

hibernate-configuration>

映射文件

<hibernate-mapping>

   <class name="com.bjpower.hibernate.User"table="t_user">

      <id name="id">

        <generator class="native">generator>

 

      id>

      <property name="name"column="t_name" />

      <property name="date"column="createtime" />

   class>

 

hibernate-mapping>





你可能感兴趣的:(javaEE开发)