content: package me.flyray.rbac.controller.websocket;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.servlet.ModelAndView;
  import org.springframework.web.socket.TextMessage;
  
  /** 
  * @author: bolei
  * @date：2017年10月19日 下午12:18:05
  * @description：类说明 
  */
  
  @Controller
  public class WebsocketController {
      @Bean//这个注解会从Spring容器拿出Bean
      public SpringWebSocketHandler infoHandler() {
          return new SpringWebSocketHandler();
      }
  
      @RequestMapping("/websocket/send")
      @ResponseBody
      public String send(HttpServletRequest request) {
          String username = request.getParameter("username");
          infoHandler().sendMessageToUser(username, new TextMessage("你好，测试！！！！"));
          return null;
      }
  }
  