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

3次阅读

共计 540 个字符,预计需要花费 2 分钟才能阅读完成。

采纳.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);
 }
}
正文完
 0