展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

ssm整合(五):与前端联调

  • 将前端页面放到webapp目录下

  • 使用springmvc放行页面

@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {
    
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/pages/**").addResourceLocations("/pages/");
        registry.addResourceHandler("/css/**").addResourceLocations("/css/");
        registry.addResourceHandler("/js/**").addResourceLocations("/js/");
        registry.addResourceHandler("/plugins/**").addResourceLocations("/plugins/");
    }
    
}
  • mvc配置类中扫描配置类路径
@Configuration
@ComponentScan({"com.itheima.controller","com.itheima.config"})
@EnableWebMvc
public class SpringMvcConfig {
}
  • 测试访问
http://localhost:8080/pages/books.html
posted @ 2022-05-25 21:46  DogLeftover  阅读(9)  评论(0编辑  收藏  举报