本文整理汇总了Java中org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry类的典型用法代码示例。如果您正苦于以下问题:Java ResourceHandlerRegistry类的具体用法?Java ResourceHandlerRegistry怎么用?Java ResourceHandlerRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceHandlerRegistry类属于org.springframework.web.servlet.config.annotation包,在下文中一共展示了ResourceHandlerRegistry类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// TODO: [email protected]/3/15 这里可能需要根据OS不同配置不同的路径,win:file后有3个/,linux:file后有2个/,因为linux的目录本身就是/开头
String separator = "/";
if( os.contains("Linux") ){//如果是linux // TODO: [email protected]/3/15 app_init 中判断OS
separator = "";
}
//win: file:///c:dir_name
//linux: file:///home/wangc/dir_name
// String reportResLocations = FILE_PREX+separator+ Param.USER_DIR+Param.HTML_PATH;
//将所有的/report/请求至html报告的本地路径
// registry.addResourceHandler("/report/**").addResourceLocations(reportResLocations);
String reportResLocations = FILE_PREX+separator+ Param.USER_DIR+Param.HTML_PATH+File.separator;
// reportResLocations = "file:///D:/workspace_HelloWorld/testing_platform/jmeter/html/";
registry.addResourceHandler("/report/**").addResourceLocations(reportResLocations);
//file:///D:/workspace_HelloWorld/testing_platform/jmeter/html
super.addResourceHandlers(registry);
}
示例2: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// css resource
registry
.addResourceHandler("/css/**")
.addResourceLocations("classpath:/static/css/");
// js resource
registry
.addResourceHandler("/js/**")
.addResourceLocations("classpath:/static/js/");
// js resource
registry
.addResourceHandler("/vendors/**")
.addResourceLocations("classpath:/static/vendors/");
// img resource
registry
.addResourceHandler("/img/**")
.addResourceLocations("classpath:/static/img/");
}
示例3: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/resources/")
.setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
;
// Add WebJars for Bootstrap & jQuery
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/").resourceChain(true);
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(
CLASSPATH_RESOURCE_LOCATIONS);
}
}
示例4: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/resources/")
.setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
.setCachePeriod(0)//Set to 0 in order to send cache headers that prevent caching
;
// Add WebJars for Bootstrap & jQuery
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/").resourceChain(true);
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(
CLASSPATH_RESOURCE_LOCATIONS);
}
}
示例5: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/resources/")
.setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
;
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/").resourceChain(true);
// Add WebJars for Bootstrap & jQuery
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/").resourceChain(true);
}
registry.addResourceHandler("/**")
.addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**")
.addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
}
}
示例6: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/resources/")
.setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
.setCachePeriod(0)//Set to 0 in order to send cache headers that prevent caching
;
// Add WebJars for Bootstrap & jQuery
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/").resourceChain(true);
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(
CLASSPATH_RESOURCE_LOCATIONS);
}
}
示例7: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/index.html")
.addResourceLocations("classpath:/public/", "classpath:/static/")
.setCacheControl(createCacheConfig(maxIndexCacheAge))
.resourceChain(true)
.addResolver(new PathResourceResolver());
final ResourceChainRegistration registration = registry.addResourceHandler("/**")
.addResourceLocations("classpath:/public/", "classpath:/static/",
"classpath:/META-INF/resources/")
.setCacheControl(createCacheConfig(maxCacheAge))
.resourceChain(true)
.addResolver(new PathResourceResolver());
if (propertyInjectionTransformer != null) {
registration.addTransformer(propertyInjectionTransformer);
}
}
示例8: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/resources/**")
.addResourceLocations("/resources/")
.setCachePeriod(3600)
.resourceChain(true)
.addResolver(new PathResourceResolver());
}
示例9: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/css/**")
.addResourceLocations("/js/")
.setCachePeriod(31556926);
}
示例10: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/css/**")
.addResourceLocations("/js/**")
.setCachePeriod(31556926);
}
示例11: addResourceHandlers
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; //导入依赖的package包/类
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
int cachePeriodInSeconds = (int) TimeUnit.DAYS.toSeconds(1);
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/")
.setCachePeriod(cachePeriodInSeconds);
}
}