一、首先把下载的dwr和spring,proxool用到的包放到工程的/WEB-INF/lib目录下
二、
1.web.xml配置
注意servlet和其他的放在一起,servlet-mapping放在一起。
2.proxool.xml配置
3.applicationContext-jdbc.xml的配置
4.dwr.xml配置
5.jsp页面
二、
1.web.xml配置
注意servlet和其他的放在一起,servlet-mapping放在一起。
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>initApplicationScopeCreatorsAtStartup</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</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>
2.proxool.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<proxool-config>
<proxool>
<alias>testdb</alias>
<driver-url>
jdbc:oracle:thin@IP:1521:test
</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-porperties>
<property name="user" value="test" />
<property name="password" value="test" />
</driver-properties>
<maximum-connection-lifetime>14400000</maximum-connection-lifetime>
<maximum-active-time>600000</maximum-active-time>
<minimum-connection-count>5</minimum-connection-count>
<maximum-connection-count>200</maximum-connection-count>
<houser-keeping-sleep-time>900000</house-keeping-sleep-time>
<house-keeping-test-sql>
SELECT CURRENT_DATE FORM DUAL
</house-keeping-test-sql>
<trace>true</trace>
</proxool>
</proxool-config>
3.applicationContext-jdbc.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN//EN"
"http://www/springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManageDataSource">
<property name="driverClassName">
<value>org.logicalcobwebs.proxool.ProxoolDriver</value>
</property>
<property name="url">
<value>proxool.tesddb</value>
<!--和proxool.xml中的<alias>中间的名一致-->
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dwrTestService" class="service接口全路径">
<property name="transactionManager" ref="transactionManager" />
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
4.dwr.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr2.0.dtd">
<dwr>
<allow>
<create creator="spring" javascript="dwr_test_service">
<param name="beanName" value="dwrTestService" /><!--value值和上面service接口配置中的id名相同-->
</create>
<!--
如果用到form或者domain需要写下面的
-->
<!--
<convert match="包名到完整的类名" converter="bean" />
-->
</allow>
</dwr>
5.jsp页面
//引用dwr的js
<script type="text/javascript" src="/dwr/engine.js"></script>
<script type="text/javascript" src="/dwr/util.js"></script>
<script type="text/javascript" src="/dwr/interface/dwr_test_service.js"></script>
<script type="text/javascript">
function test() {
dwr_test_service.testMethod(callBack);
}
// 回调函数
function callBack(){
}
</script>