static-resource

Serve static resources within jar files by Spring boot

最后都变了- 提交于 2019-12-22 08:16:03
问题 I'm developing a solution by multiple maven modules to handle different bounded contexts. Thanks to spring boot each module exposes own rest api and all of them hosted in one maven module with a class that annotated by @SpringBootApplication. The simplified project structure is looks like this: parent |-- pom.xml |-- ... |-- host |-- Application.java |-- resources |-- index.html |-- driver |-- api |-- resources |-- register.html |-- notify |-- ... |-- passenger |-- ... I've tried to use the

Spring controller mapping configuration and static resources

本小妞迷上赌 提交于 2019-12-13 01:27:22
问题 I have an issue with intercepting request to static resources by controller. Here is web.xml (part related with the problem): <servlet> <servlet-name>testing</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>testing</servlet-name> <url-pattern>/testing/*</url-pattern> </servlet-mapping> Here is testing-servlet.xml: <mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/WEB-INF

How to give path for external javascript file inside WEB-INF in JSP

时光总嘲笑我的痴心妄想 提交于 2019-12-12 04:03:35
问题 I am developing Spring web application. my application package structure is web/----| |WEB-INF/ |-jsps/ |-scripts/ |-styles/ |-web.xml It is Spring MVC & maven based project. I have to use the external javascript file in jsp file. if I use <script src="/scripts/MyFile.js"/> is not working as the resource is inside WEB-INF . I have tried so many ways but I could not find solution. So could you please tell me how to access external javascript file from JSP file. Note: I cant change my Directory

Spring Boot MVC request mapping overrides static resources

淺唱寂寞╮ 提交于 2019-12-11 08:33:16
问题 I want to have rest controller in Spring Boot to handle all requests like this: "/{arg}", EXCEPT "/sitemap.xml". How can I achieve that? 回答1: You could specify your request mapping on the controller level via regex and exclude some resources (e.g. 'excludeResourceA' and 'excludeResourceB') with: @RestController @RequestMapping(value = "/{arg:(?!sitemap.xml|excludeResourceA|excludeResourceB).*$}") public class YourRestController { // your implementation } Of course you can also specify the

Serving static resources in spring security - Allow access to all files in '/resources/public'

 ̄綄美尐妖づ 提交于 2019-12-11 02:08:38
问题 I can serve static resources perfectly fine with this setup however I have to define on a file by file basis the files which are allowed to be served. My current use case is anything located in the /resources/public/ directory should have allowed access by clients. i've tried the one liner /resources/public/** and /public/** that still doesn't allow access to all public resources i get 403's. So in my http configure i've started defining file extensions that are permitted, but i don't like

Spring MVC default-servlet-handler configuration blocking JSTL view

匆匆过客 提交于 2019-12-08 12:08:38
问题 I have simple Spring configuration <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix"> <value>/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <!-- Scan for components under this package --> <context:component-scan base-package="com.osfg.test" /> And my controller is package com.osfg.test; import org.springframework.stereotype.Controller; import org.springframework.web.bind

Thymeleaf + Spring-Boot - why can't I access static resources?

纵饮孤独 提交于 2019-12-08 10:45:17
问题 My project tree looks like this: I can access the templates now, but can't load static resources such as CSS, images, and JS. I have a common.html fragment where I declare all my static resources, for instance: <link rel="stylesheet" th:href="@{/css/app.css}"/> A header fragment where I include common.html like so: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <head th:include="fragments/common :: commonFragment" lang="en"></head> // page body

Serve static resources within jar files by Spring boot

穿精又带淫゛_ 提交于 2019-12-05 16:03:18
I'm developing a solution by multiple maven modules to handle different bounded contexts. Thanks to spring boot each module exposes own rest api and all of them hosted in one maven module with a class that annotated by @SpringBootApplication. The simplified project structure is looks like this: parent |-- pom.xml |-- ... |-- host |-- Application.java |-- resources |-- index.html |-- driver |-- api |-- resources |-- register.html |-- notify |-- ... |-- passenger |-- ... I've tried to use the same pattern when facing with the composite UI: one place that keeps layouts, static resources and in

Spring Boot not loading static resources it depends on RequestMapping depth

自作多情 提交于 2019-12-02 19:45:54
问题 I have problem to load the file under static folder on spring boot application. The problem is RequestMapping depth more than 2 like @RequestMapping("spring/xyz") The @RequestMapping("spring") single depth works well but 2 depth is prefixed 'spring' it is connect localhost:8080/spring/'static folder' I found half solution here my folder structure is: static/css/some.css static/templates/velocity.vm case 1: works well java: @RequestMapping("spring") html: <link rel="stylesheet" href="css/some

Spring Boot not loading static resources it depends on RequestMapping depth

≯℡__Kan透↙ 提交于 2019-12-02 08:23:39
I have problem to load the file under static folder on spring boot application. The problem is RequestMapping depth more than 2 like @RequestMapping("spring/xyz") The @RequestMapping("spring") single depth works well but 2 depth is prefixed 'spring' it is connect localhost:8080/spring/'static folder' I found half solution here my folder structure is: static/css/some.css static/templates/velocity.vm case 1: works well java: @RequestMapping("spring") html: <link rel="stylesheet" href="css/some.css"> case2: works well java: @RequestMapping("spring/xyz") html: <link rel="stylesheet" href="../css