brian661
brian661

Reputation: 548

Set spring resources folder base path

I would like to add my application name as the resources folder base path

# For example, from
http://localhost:8081/1/imgs/someImage.jpg  
http://localhost:8081/1/css/common.css

# to 
http://localhost:8081/myAppName/1/imgs/someImage.jpg  
http://localhost:8081/myAppName/1/css/common.css

# with some spring resources configuration in application.properties
spring.resources.chain.strategy.fixed.enabled=true
spring.resources.chain.strategy.fixed.version=1

How can I set it?
Thanks in advance.

Upvotes: 2

Views: 2007

Answers (1)

Dimitri Mestdagh
Dimitri Mestdagh

Reputation: 44745

You can do this by customising the spring.mvc.static-path-pattern property, eg.:

spring.mvc.static-path-pattern=/myName/**

This is also mentioned in the docs:

By default, resources are mapped on /** but you can tune that via spring.mvc.static-path-pattern. For instance, relocating all resources to /resources/** can be achieved as follows:

spring.mvc.static-path-pattern=/resources/**

Upvotes: 1

Related Questions