ssh的配置

一。普通模式

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:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
	<!-- dataSource -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
		<property name="url"
			value="jdbc:mysql://192.168.102.33:3306/contact?characterEncoding=UTF-8"></property>
		<property name="username" value="root"></property>
		<property name="password" value="hejie"></property>
	</bean>
	<!-- sessionFactory -->
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<property name="hibernateProperties">
			<props>
				<prop key='hibernate.dialect'>org.hibernate.dialect.MySQLDialect
				</prop>
				<prop key='hibernate.show_sql'>true</prop>
				<prop key='hibernate.format_sql'>true</prop>
			</props>
		</property>
		<property name="mappingResources">
			<list>
				<value>com/ycr/entity/TestEntity.hbm.xml
				</value>
			</list>
		</property>
	</bean>
	<!-- hibernateTemplate -->
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	<!-- trace -->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	<!-- 拦截  -->
	<bean id="interceptor"
		class="org.springframework.transaction.interceptor.TransactionInterceptor">
		<property name="transactionManager" ref="transactionManager"></property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	<!-- 代理 -->
	<bean id="autoproxy"
		class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
		<property name="beanNames">
			<list>
				<value>*Service</value>
			</list>
		</property>
		<property name="interceptorNames">
			<list>
				<value>interceptor</value>
			</list>
		</property>
	</bean>

	<!-- dao -->
	<bean id="testDao" class="com.ycr.dao.impl.TestDaoImpl">
		<property name="template" ref="hibernateTemplate"></property>
	</bean>
	<!-- service -->
	<bean id="testService" class="com.ycr.service.impl.TestServiceImpl">
		<property name="testDao" ref="testDao"></property>
	</bean>

	<!-- action -->
	<bean id="testAction" class="com.ycr.web.TestAction">
		<property name="ts" ref="testService"></property>
	</bean>
</beans>

webservice配置信息。也是在spring中的,只不过我把其提出来了

<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
        				   http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        				   http://cxf.apache.org/jaxws 
        				   http://cxf.apache.org/schemas/jaxws.xsd"
      default-autowire="byName" default-lazy-init="false" >
    
	<!-- Import Apache CXF Bean Definition -->
    <import resource="classpath:META-INF/cxf/cxf.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
    
	<!-- web service的spring配置  address为url serviceClass接口类-->
    <jaxws:server id="eTestService" 
    			  serviceClass="com.ycr.service.TestService" 
        		  address="/eTestService">
        <jaxws:serviceBean>
             <!-- service bean的id -->
            <ref bean="testService"/>
        </jaxws:serviceBean>
    </jaxws:server>
	

</beans>

  

 

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>
    <package extends="struts-default" name="sr">
    	<action name="testAction" class="testAction" >
    		<result name="success" >index.jsp</result>
    	</action>
    </package>
</struts>

 

hibernate映射文件

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
	<class name="com.ycr.entity.TestEntity" table="TestEntity">
		<id name="id" type="java.lang.Integer">
			<column name="id" />
			<generator class="increment" />
		</id>

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

	</class>
</hibernate-mapping>

 

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">
	
  
  <context-param>
  	<param-name>contextConfigLocation</param-name>
  	<param-value>
  		classpath*:applicationCon*.xml;
  		classpath*:ws-user.xml;
  	</param-value>
  </context-param>
  <listener>
  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  <!-- web service -->
  <servlet>
  	<servlet-name>webservice</servlet-name>
  	<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  	<servlet-name>webservice</servlet-name>
  	<url-pattern>/ws/*</url-pattern>
  </servlet-mapping>
  
  <!-- struts2 -->
  <filter>
  	<filter-name>str2</filter-name>
	<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>str2</filter-name>
  	<url-pattern>*.action</url-pattern>
  </filter-mapping>
  <filter-mapping>
  	<filter-name>str2</filter-name>
  	<url-pattern>*.jsp</url-pattern>
  </filter-mapping>
  
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

 

OK了!

 

 

 

二。tx:advice  模式

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值