部署在tomcat

时间:2018-06-27 19:12:15

标签: spring spring-mvc spring-boot static-resource

我有跟随的项目结构。

enter image description here

现在,我想从资源/静态/资源中加载静态资源。我试图在我的mvc配置中添加以下内容,但没有成功。

    registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
    registry.addResourceHandler("/**").addResourceLocations("classpath:/static/resources/");
registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/static/");
    registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/static/resources/");

我要访问静态目录下的资源目录

 <script type="text/javascript" src="/resources/scripts/jquery-3.3.1.min.js"></script>

任何帮助或建议表示赞赏。谢谢。

还尝试了以下操作,

    registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
       registry.addResourceHandler("/**").addResourceLocations("classpath:/static/resources/");
       registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/static/");
       registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/static/resources/");
       registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
       registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
       registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/resources/");
       registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
       registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/static/resources/");
       registry.addResourceHandler("/**").addResourceLocations("classpath:/");
       registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");

registry.addResourceHandler("/**").addResourceLocations("/WEB-INF/classes/static/");
       registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/classes/static/resources/");
       registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/static/resources/");

但是不起作用。

0 个答案:

没有答案