关于websocket在spring项目握手失败的问题

用java实现的websocket
我在不适用其他框架的时候可以正常握手访问
但是最近加在一个适用spring的项目中,一直握手不成功,这是什么原因?
以下是浏览器返回的信息

 Request URL:ws://127.0.0.1:8080/springDemo/websocket/roomName/roomId
Request Method:GET
Status Code:404 Not Found
Response Headers
 (5)
Request Headers
view source
Accept-Encoding:gzip, deflate, sdch
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:no-cache
Connection:Upgrade
Cookie:JSESSIONID=1FF3C077231B22FAE14E6CCD5E68FBF6
Host:127.0.0.1:8080
Origin:http://127.0.0.1:8080
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:pUvNNKdq1RM3Sl7F0+rIIw==
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

我spring配置信息是这样的

 <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:jdbcOracle.properties" />
  </bean>
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driver}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="autoCommitOnClose" value="true" />
        <property name="checkoutTimeout" value="${cpool.checkoutTimeout}" />
        <property name="initialPoolSize" value="${cpool.minPoolSize}" />
        <property name="minPoolSize" value="${cpool.minPoolSize}" />
        <property name="maxPoolSize" value="${cpool.maxPoolSize}" />
        <property name="maxIdleTime" value="${cpool.maxIdleTime}" />
        <property name="acquireIncrement" value="${cpool.acquireIncrement}" /> 
    </bean>

    <!-- 数据库 事务管理器 -->
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
      <!-- 创建SqlSessionFactory,同时指定数据源 -->  
   <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="dataSource" ref="dataSource"/>
        <!-- 自动扫描mapping.xml文件 -->
         <property name="mapperLocations" >
            <list>
                <value>classpath*:com/bs/gpms/**/mapper/*.xml</value>
                <value>classpath*:com/bs/basic/base/dao/*.xml</value>
            </list>
        </property>

    </bean>
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
    <property name="annotationClass" value="org.springframework.stereotype.Repository"/>  
    <property name="basePackage" value="com.bs.gpms"/>  

    </bean>    
    <!-- <bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" />
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:SqlMapConfig.xml" />
        <property name="lobHandler" ref="lobHandler" />
    </bean> -->
    <!-- 基于注释的事务,当注释中发现@Transactional时,使用id为“transactionManager”的事务管理器  -->
    <!-- 如果没有设置transaction-manager的值,则spring以缺省默认的事务管理器来处理事务,默认事务管理器为第一个加载的事务管理器 -->
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <!-- <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
        <property name="sqlMapClient" ref="sqlMapClient" />
    </bean> -->
     <mvc:annotation-driven>
    <mvc:message-converters>
        <bean class="org.springframework.http.converter.StringHttpMessageConverter">
            <property name="supportedMediaTypes">
                <list>
                    <value>application/json;charset=UTF-8</value>
                </list>
            </property>
        </bean>
    </mvc:message-converters>
    </mvc:annotation-driven> 
    <context:annotation-config />  


    <context:component-scan base-package="com.*" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/" />
        <property name="suffix" value=".jsp" />
    </bean>

一直找不到问题,因为这是旧项目,也没办法更新到spring4

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐