关于html:拦截以-html-结尾的url-开启匹配后缀

采纳.html结尾的页面,更加容易被搜索引擎收录,进步网站的曝光率.
案例:


心愿通过*/index.html 拜访的是index.jsp而不是真的index.html
那就须要拦挡以 .html 结尾的url 跳转到index.jsp

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration //等同于web.xml配置文件
public class MvcConfigurer implements WebMvcConfigurer{
 //开启匹配后缀型配置
 @Override
 public void configurePathMatch(PathMatchConfigurer configurer) {
 //开启匹配后缀型配置 .html configurer.setUseSuffixPatternMatch(true);
 }
}

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理