package com.websocket; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /** * 配置viewController,为ws.html提供便捷的映射路径 * Created by Administrator on 2016/12/6. */ @Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void addViewControllers(ViewControllerRegistry registry) { //第一个ws指定请求路径,第二个/ws指对应的视图名称,这里是/templates/ws.html //访问地址http://localhost:8080/ws registry.addViewController("ws").setViewName("/ws"); } }
转载于:https://my.oschina.net/NeedLoser/blog/800914