问题标签 [static-resource]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
spring - Spring 中的静态资源不起作用。有任何想法吗?
情况:
我有一个来自 start.spring.io 的新春季项目
并且我已经创建了文件project/src/main/resources/js/a.js
我还创建了project/src/main/resources/templates/index.html
(它与百里香一起)需要a.js
它<script th:src="@{/js/a.js}"></script>
我也有以下配置:
当应用程序启动时,我可以在日志中看到:
Mapped URL path [/js/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
试过:
- 在
.addResourceLocations();
我尝试了各种变体,例如:"/resources/js"
,"resources/js"
,"/js"
,"js"
- 也在
application.properties
使用中spring.resources.static-locations=classpath:/resources/
- 相应地创建
/resources/static/js/a.js
和更新addResourceLocatios
参数
有任何想法吗?
spring - Spring Boot 上传文件并将其作为静态资源提供服务
是否可以使用 Spring / Spring Boot 来支持文件上传并将上传的文件作为静态资源提供服务?
我遵循官方教程 ,以便我的应用程序可以处理文件上传,但是当我尝试将存储根目录设置为静态资源文件夹时,它不起作用。
而且我不想将文件上传到另一台服务器或 AWS S3。
如何使用 Spring / Spring Boot 支持文件上传并将上传的文件作为静态资源提供服务?
java - 在 Spring Security 中提供静态资源 - 允许访问“/resources/public”中的所有文件
我可以通过此设置完美地提供静态资源,但是我必须逐个文件定义允许提供的文件。
我当前的用例是/resources/public/
目录中的任何内容都应该允许客户端访问。
我已经尝试过一个班轮/resources/public/**
,/public/**
但仍然不允许访问我得到 403 的所有公共资源。因此,在我的 http 配置中,我已经开始定义允许的文件扩展名,但我不喜欢这种方法,因为我的 webapp 中有很多不同的扩展名。
我的问题是我怎样才能允许访问所有文件/resources/public/
而不必为每个文件扩展名定义蚂蚁匹配器,或者我只是小气?
Spring WebSecurityConfigurerAdapter
- 根据 jmw5598 的回答进行编辑。
用于服务 Web 应用程序的控制器:
我的目录结构在/resources
spring - 通过浏览器访问 Heroku Spring Web 应用程序上的静态资源
我的项目中有 3 个static.txt
s,但是访问https://magicsapp.herokuapp.com/static.txt时出现 404 错误。
src/main/resources/application.properties
有这条线,
但是当我提交时,会出现警告:
当我连接到该地址时,实际访问的是哪个文件(或什么路径)?
namespaces - 无法在具有命名空间的 Lightning 容器中加载静态资源
我的组织有一个命名空间,我正在尝试在我的闪电组件中的闪电:容器中加载静态资源。我的闪电组件和静态资源都具有相同的命名空间。浏览器抱怨 Salesforce 将静态资源解析到的服务器 URL 不可访问。以前有没有人成功过这个?
这是我的闪电容器的定义方式:
spring - Static resource mapping in Spring3
My project is implemented in Spring3 and configuration is almost xml. Configuration of static resource mapping is like below:
There is no problem when accessing /a/xxx.jpg but 404 Error is occurred when accessing subdirectory like /a/b/yyy.jpg. There is no problem about access authority of filesystem. How can I solve this problem? Additional configuration is needed?
(Add) Project directory is fine, but filesystem directory does not work
javascript - Spring Boot 2:一些静态资源没有加载
/static/
我在 Spring Boot 应用程序的路径中添加了静态资源。
当页面加载一些css
并且js
文件没有加载时。例如:/static/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css
已加载,但是,/static/js/jquery-ui/js/jquery-ui-1.10.3.minimal.min.js
资源/static/css/font-icons/entypo/css/entypo.css
未加载 - 返回 404。如果我将这些资源在文件夹树中向上移动 1 或 2 级,则这些资源可以访问,因此我可以使用直接 url 下载它们。但我不想这样做。因为它们是某些模板的一部分,移动会损坏主题结构。