本文介绍了Spring MVC mvc:资源位置属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我在加载静态资源时也遇到了问题.

Guys I have also problem with loading static resources.

我认为我已经正确设置了所有内容.但是我不理解 mvc:resources location 属性.有什么用?

I think I have everything properly set up. But I don't understand location attribute of mvc:resources. What is it for?

如果我的静态资源位于位置VAADIN/themes/theme/...(在几个子文件夹,图像,css,js中),则位置和映射属性的正确值应该是什么?

if I have my static resources under location VAADIN/themes/theme/... (in several subfolders, images, css, js) what should be the correct values for location and mapping attributes?

当我进行以下配置时:

<mvc:resources location="/VAADIN/" mapping="/VAADIN/**"/>

它不起作用.我想日志的以下部分是相关的:

it doesn't work. I suppose the following part of log is related:

17:15:02.897 [http-8080-2] DEBUG o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#6': no
 URL paths identified

例如,我收到 HTTP状态404 . http://127.0.0.1/VAADIN/themes/theme/css/style.css

推荐答案

location是放置资源的文件夹的位置. XSD文档写道:

location is the location to the folder where the resources are placed. The XSD docs write:

另一方面,mapping属性是:

因此mapping指定在网络上可以访问哪些uri,而location指定这些资源在磁盘上的位置.

So mapping specifies under what uri will resources be accessible on the web, while location specifies where are these resources located on the disk.

这篇关于Spring MVC mvc:资源位置属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 04:44