首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

ssh项目配置文件摘记

2012-09-01 
ssh项目配置文件摘录项目一web.xml?xml version1.0 encodingUTF-8?web-app version2.5 xmlns

ssh项目配置文件摘录
项目一
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<servlet>
  <servlet-name>Connector</servlet-name>
  <servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
  </servlet>

<!-- initialize log4j --> 
<servlet> 
    <servlet-name>log4j config file</servlet-name> 
    <servlet-class>org.ethip.catalog.common.Log4jInitServlet</servlet-class> 
    <init-param> 
        <param-name>configfile</param-name> 
        <param-value>/WEB-INF/classes/log4j.properties</param-value> 
    </init-param> 
      
    <load-on-startup>1</load-on-startup> 
</servlet>

<servlet>
<servlet-name>treeMenuServlet</servlet-name>
<servlet-class>org.ethip.catalog.common.TreeMenuServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>treeMenuServlet</servlet-name>
<url-pattern>/treeMenuServlet</url-pattern>
</servlet-mapping>
  <servlet-mapping>
  <servlet-name>Connector</servlet-name>
  <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
  </servlet-mapping>
  <!-- FCKeditor配置 -->
<!-- spring的应用上下文 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>

<filter>
        <filter-name>struts-cleanup</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.ActionContextCleanUp
        </filter-class>
    </filter>
   
   

<!-- struts2 过滤器 -->
<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>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

<listener>
<listener-class>
org.ethip.catalog.common.SessionCounter
</listener-class>
</listener>

<!-- spring的监听器,以便在启动时就自动加载spring的配置 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- OpenSessionInViewFilter过滤器 -->
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>

<welcome-file-list>
<welcome-file>index.action</welcome-file>
</welcome-file-list>
</web-app>


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

<struts>
<include file="struts-default.xml" />
<!-- 此constant设置临时文件存放目录,因为默认的default.properties中没有指定 -->
<constant name="struts.multipart.saveDir" value="c:"></constant>
<constant name="struts.multipart.maxSize" value="1000000000" />
<!-- 将action托管给spring -->
<constant name="struts.objectFactory" value="spring"></constant>
<package name="SSH2" extends="struts-default">
<!-- 管理员登录 -->
<action name="login" method="login" > 
        <result name="success" type="dispatcher">/jsp/manager.jsp</result> 
        <result name="none" type="redirect">liuyanManageList.action</result>
        <result name="error">/jsp/login.jsp</result> 
        <result name="input">/jsp/errs.jsp</result>
    </action>   
<action name="logout" method="logout" > 
        <result name="success" type="redirect">/jsp/login.jsp</result> 
        <result name="input">/jsp/errs.jsp</result>
</action>
</package>
</struts>


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.5.xsd
http://www.springframework.org/schema/tx
                     http://www.springframework.org/schema/tx/spring-tx.xsd
                     http://www.springframework.org/schema/aop
                     http://www.springframework.org/schema/aop/spring-aop.xsd">


<bean id="dataSource"
value="root"></property>
<property name="password" value="02416220"></property>
</bean>
<bean id="sessionFactory"
/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>

<property name="mappingResources">
<list>
<value>org/ethip/catalog/model/User.hbm.xml</value>
<value>org/ethip/catalog/model/Gaikuang.hbm.xml</value>
<value>org/ethip/catalog/model/Lanmu.hbm.xml</value>
<value>org/ethip/catalog/model/Manager.hbm.xml</value>
<value>org/ethip/catalog/model/News.hbm.xml</value>
<value>org/ethip/catalog/model/Shiping.hbm.xml</value>
<value>org/ethip/catalog/model/Zsjigou.hbm.xml</value>
<value>org/ethip/catalog/model/Company.hbm.xml</value>
<value>org/ethip/catalog/model/Liuyan.hbm.xml</value>
<value>org/ethip/catalog/model/Tree.hbm.xml</value>
<value>org/ethip/catalog/model/Other.hbm.xml</value>
</list>
</property>
</bean>
<bean id="GaikuangDAO" />
</property>
</bean>

<bean id="GaikuangService"
/>
</property>
</bean>
<bean name="editGaikuangBean" />
</property>
</bean>

<!-- other -->
<bean name="listTreeBean" />
</property>
</bean>


<bean id="UserDAO" />
</property>
</bean>
<!-- news -->
<bean id="NewsDAO" />
</property>
</bean>


<bean id="UserService"
/>
</property>
</bean>
<bean name="addUserBean" />
</property>
</bean>

<!-- news -->
<bean id="NewsService"
/>
</property>
</bean>


<!--  实施事务管理的bean   -->
<bean id="transactionManager"
/>
</property>
</bean>
<!--给事务添加的属性  -->

<tx:advice id="txAdvice" transaction-manager="transactionManager"> 
     <tx:attributes > 
<!--propagation表示的是事务的传播特性,使用required时,是当检测到add开头的方法时,就看此时有没有开启的事务,如果有则将方法放进事务中去,如果没有,则新建一个事务。然后将方法放进去。 --> 
          <tx:method name="save*" propagation="REQUIRED"/> 
          <tx:method name="delet*" propagation="REQUIRED"/> 
           <tx:method name="update*" propagation="REQUIRED"/>  
<!--如果检测到其它的方法,则给其只读数据库的属性。即当本方法在读时,其它的方法不能再去写了。保证一个事务的完整性。   -->
           <tx:method name="*" read-only="true"/> 
</tx:attributes> 
</tx:advice>
<aop:config> 
      <aop:pointcut id="allManagerMethod"   
expression="execution(* org.ethip.catalog.service.*.*(..))"/>  
<!-- 调用上面配置的事务属性,可以将它给本aop pointcut。    -->
      <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/> 
<!-- 如果还有其它的定义,则可以再加上pointcut、advisor来定义本切面点的事务逻辑。    -->
</aop:config>


</beans>

热点排行