我想实现在系统启动时自动调用监听器中的方法。但无论把监听器配在哪里都无法成功部署。都是卡在一个位置不动
web.xml配置。
 <!-- 启动创建spring容器 -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
   <param-value>classpath:spring-*.xml</param-value>
  </context-param>  <listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
<!-- 自定义的监听器 -->
  <listener>
   <listener-class>taobao.socket.server.TaobaoServer</listener-class>
  </listener>
  <!-- struts控制器 -->
  <filter>
   <filter-name>StrutsFilter</filter-name>
   <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  
  <filter-mapping>
   <filter-name>StrutsFilter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!-- session存活时间 -->
 <session-config>
  <session-timeout>30</session-timeout>
 </session-config>

解决方案 »

  1.   

    从配置文件上看,是没有问题的。TaobaoServer类实现HttpSessionListener接口了么?
      

  2.   

    tomcat卡了还是程序卡了,卡在哪儿了?
      

  3.   


    你試試,將你自己定義的監聽器的位置在web.xml中移動到最前面。
      

  4.   

    解决了,是自己昏了头,没开辟新线程。Socket cs=ss.accept(8080);卡住了。