宝贝腿开大点我添添你视频男男,中文字幕熟女人妻av一区二区三区,爱色成人网,大地资源高清播放在线观看在线电影在线观看 ,777米奇影视第四色

集團站切換校區(qū)

驗證碼已發(fā)送,請查收短信

復制成功
微信號:togogoi
添加微信好友, 詳細了解課程
已復制成功,如果自動跳轉微信失敗,請前往微信添加好友
打開微信
圖標

學習文章

當前位置:首頁 > >學習文章 > >

{SpringBoot}web開發(fā)

發(fā)布時間: 2019-01-16 17:17:08

?springboot引入靜態(tài)資源

ctrl+n 全局搜索 (WebMvc)

?

@Override

public void addResourceHandlers(ResourceHandlerRegistry registry) {

if (!this.resourceProperties.isAddMappings()) {

logger.debug("Default resource handling disabled");

return;

}

Duration cachePeriod = this.resourceProperties.getCache().getPeriod();

CacheControl cacheControl = this.resourceProperties.getCache()

.getCachecontrol().toHttpCacheControl();

if (!registry.hasMappingForPattern("/webjars/**")) {

customizeResourceHandlerRegistration(registry

.addResourceHandler("/webjars/**")

.addResourceLocations("classpath:/META-INF/resources/webjars/")

.setCachePeriod(getSeconds(cachePeriod))

.setCacheControl(cacheControl));

}

String staticPathPattern = this.mvcProperties.getStaticPathPattern();

if (!registry.hasMappingForPattern(staticPathPattern)) {

customizeResourceHandlerRegistration(

registry.addResourceHandler(staticPathPattern)

.addResourceLocations(getResourceLocations(

this.resourceProperties.getStaticLocations()))

.setCachePeriod(getSeconds(cachePeriod))

.setCacheControl(cacheControl));

}

}


//配置歡迎頁面

@Bean

public WelcomePageHandlerMapping welcomePageHandlerMapping(

ResourceProperties resourceProperties) {

return new WelcomePageHandlerMapping(resourceProperties.getWelcomePage(),

this.mvcProperties.getStaticPathPattern());

}


//配置喜歡的圖標

@Configuration

@ConditionalOnProperty(value = "spring.mvc.favicon.enabled", matchIfMissing = true)

public static class FaviconConfiguration {


private final ResourceProperties resourceProperties;


public FaviconConfiguration(ResourceProperties resourceProperties) {

this.resourceProperties = resourceProperties;

}


@Bean

public SimpleUrlHandlerMapping faviconHandlerMapping() {

SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();

mapping.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);

//所有  **/favicon.ico

mapping.setUrlMap(Collections.singletonMap("**/favicon.ico",

faviconRequestHandler()));

return mapping;

}


@Bean

public ResourceHttpRequestHandler faviconRequestHandler() {

ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler();

requestHandler

.setLocations(this.resourceProperties.getFaviconLocations());

return requestHandler;

}

}

所有 /webjars/** ,都去 classpath:/META-INF/resources/webjars/ 找資源;

?webjars:以jar包的方式引入靜態(tài)資源;?

https://www.webjars.org/ 找到需要引入的資源文件 寫到pom中:?

?

<dependency>

   <groupId>org.webjars</groupId>

   <artifactId>jquery</artifactId>

   <version>3.3.1</version>

</dependency>


?http://localhost:8080/webjars/jquery/3.3.1/jquery.js 即可訪問jquery;

?自定義的靜態(tài)資源存放:ResourceProperties?

"/**" 訪問當前項目的任何資源,都去(靜態(tài)資源的文件夾)找;

?

{

"classpath:/META-INF/resources/", "classpath:/resources/",

"classpath:/static/", "classpath:/public/" };

"/":當前項目的根路徑


自定義圖標

命名為favicon.ico,放在靜態(tài)文件夾下即可!

自定義靜態(tài)文件存放路徑:spring.resources.static-locations=classpath:/qmk

上一篇: {HTML5}DOM節(jié)點操作-第三節(jié)

下一篇: {HTML5}DOM節(jié)點操作-第二節(jié)

十九年老品牌
微信咨詢:gz_togogo 咨詢電話:18127429208 咨詢網站客服:在線客服

相關課程推薦

在線咨詢 ×

您好,請問有什么可以幫您?我們將竭誠提供最優(yōu)質服務!