#87 - Fix WebJARs resource handling in Starbucks example.
This commit is contained in:
committed by
Oliver Gierke
parent
5f132037e3
commit
cc2ac546e7
43
rest/starbucks/src/main/java/example/stores/WebConfig.java
Normal file
43
rest/starbucks/src/main/java/example/stores/WebConfig.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package example.stores;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
||||
|
||||
/**
|
||||
* Temporarily required manual configuration of resource handling to activate the resource chain handling.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/webjars/**").//
|
||||
addResourceLocations("classpath:/META-INF/resources/webjars/").//
|
||||
resourceChain(true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
|
||||
return new ResourceUrlEncodingFilter();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<link rel="stylesheet" href="/webjars/bootstrap/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" th:href="@{/webjars/bootstrap/css/bootstrap.min.css}"/>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@@ -97,13 +97,13 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="/webjars/jquery/jquery.min.js"></script>
|
||||
th:src="@{/webjars/jquery/jquery.min.js}"></script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="/webjars/bootstrap/js/bootstrap.min.js"></script>
|
||||
th:src="@{/webjars/bootstrap/js/bootstrap.min.js}"></script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="/webjars/URI.js/URI.min.js"></script>
|
||||
th:src="@{/webjars/URI.js/URI.min.js}"></script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="//maps.google.com/maps/api/js?sensor=false"></script>
|
||||
|
||||
Reference in New Issue
Block a user