当前位置:编程学习 > JAVA >>

servlet+spring+flex整合中遇到的问题

--------------------编程问答-------------------- 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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
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/context   
    http://www.springframework.org/schema/context/spring-context-2.5.xsd  
    http://www.springframework.org/schema/tx   
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
    http://www.springframework.org/schema/aop   
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    ">

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/jdbc.properties" />
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass">
<value>${driverClass}</value>
</property>
<property name="jdbcUrl">
<value>${jdbcUrl}</value>
</property>
<property name="user">
<value>${user}</value>
</property>
<property name="password">
<value>${password}</value>
</property>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<!-- 配置bean -->
<bean id="jdbcbasedao" class="my.flex.dao.JdbcBaseDao">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>
</bean>
<!-- 配置SERVICE -->
<!--
<bean id="userInfoService"
class="my.flex.service.impl.UserInfoServiceImpl"> <property
name="userInfoDao" ref="userInfoDao"></property> </bean>
-->
<context:annotation-config></context:annotation-config>
<context:component-scan base-package="my.flex.servlet"></context:component-scan>
</beans>
--------------------编程问答-------------------- web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

<display-name>BlazeDS</display-name>
<description>BlazeDS Application</description>

<!-- Http Flex Session attribute and binding listener support -->
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
<description>启动spring上下工厂的易做图</description>
<listener-class>
org.springframework.web.context.ContextLoaderListener 
        </listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<!-- 過濾器 -->
<filter>
<filter-name>Encoding</filter-name>
<filter-class>
my.flex.filter.SetCharacterEncodingFilter  
     </filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
<!--gbk或者gb2312或者utf-8-->
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Encoding</filter-name>
<servlet-name>/*</servlet-name>
</filter-mapping>


<!-- MessageBroker Servlet -->
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>my.flex.servlet.ServletToBeanProxy</servlet-class>
</servlet>
<servlet>
<servlet-name>testServlet1</servlet-name>
<servlet-class>my.flex.servlet.ServletToBeanProxy</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>testServlet1</servlet-name>
<url-pattern>/TestServlet1</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>

<!-- for WebSphere deployment, please uncomment -->
<!--
<resource-ref> <description>Flex Messaging WorkManager</description>
<res-ref-name>wm/MessagingWorkManager</res-ref-name>
<res-type>com.ibm.websphere.asynchbeans.WorkManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope> </resource-ref>
-->

</web-app>

--------------------编程问答-------------------- JdbcBaseDao.java

package my.flex.dao;

import org.springframework.jdbc.core.support.JdbcDaoSupport;

public class JdbcBaseDao extends JdbcDaoSupport {

public int insert(String hql, Object[] args) {
return getJdbcTemplate().update(hql, args);
}
}
补充:Java ,  Java EE
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,