ResourcesConfig.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.ruoyi.framework.config;
  2. import org.springframework.beans.factory.annotation.Value;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  5. import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
  6. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  7. /**
  8. * 通用配置
  9. *
  10. * @author ruoyi
  11. */
  12. @Configuration
  13. public class ResourcesConfig implements WebMvcConfigurer
  14. {
  15. /**
  16. * 首页地址
  17. */
  18. @Value("${shiro.user.indexUrl}")
  19. private String indexUrl;
  20. /**
  21. * 默认首页的设置,当输入域名是可以自动跳转到默认指定的网页
  22. */
  23. @Override
  24. public void addViewControllers(ViewControllerRegistry registry)
  25. {
  26. registry.addViewController("/").setViewName("forward:" + indexUrl);
  27. }
  28. @Override
  29. public void addResourceHandlers(ResourceHandlerRegistry registry)
  30. {
  31. /** 头像上传路径 */
  32. registry.addResourceHandler("/profile/**").addResourceLocations("file:" + RuoYiConfig.getProfile());
  33. /** swagger配置 */
  34. registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
  35. registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
  36. }
  37. }