一、问题描述

  使用SpringBoot配置了 server.servlet.path后无效,访问时无法通过:http://127.0.0.1:8080/app/hello.html 访问。

二、解决方法一:

  

server:
address: 0.0.0.0
port: 8080
tomcat:
uri-encoding: utf-8
servlet:
context-path: "/app"
path: "*.html" spring:
servlet:
multipart:
max-request-size: 50Mb
max-file-size: 50Mb
mvc:
pathmatch:
use-suffix-pattern: true #启用这个之后, server.servlet.path配置后缀才会生效。 constant:
company: Yungoal
address: 北京市上地九街数码科技广场 logging:
level:
root: error
org.springframework.web: ERROR
com.yungoal: debug

如图:

  

  

三、解决方法二:

@Configuration
public class CustomwebMvcConfigurer implements WebMvcConfigurer {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseRegisteredSuffixPatternMatch(true);
}
}
@Bean
public ServletRegistrationBean servletRegistrationBean(DispatcherServlet dispatcherServlet) {
ServletRegistrationBean<DispatcherServlet> servletServletRegistrationBean = new ServletRegistrationBean<>(dispatcherServlet);
servletServletRegistrationBean.addUrlMappings(Arrays.asList("*.html"));
return servletServletRegistrationBean;
}

使用SpringBoot配置了 server.servlet.path后无效的解决方案的更多相关文章

  1. servlet修改后无效,仍然还是修改之前的效果

    注意servlet的路径是否正确,默认是java resources文件夹中的src.当在webcontent->web-inf->classses->data中时,注意添加路径.否 ...

  2. springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息

    1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...

  3. SpringBoot配置属性之Server

    SpringBoot配置属性系列 SpringBoot配置属性之MVC SpringBoot配置属性之Server SpringBoot配置属性之DataSource SpringBoot配置属性之N ...

  4. SQL Server安装完成后3个需要立即修改的配置选项(转载)

    你用安装向导安装了全新的SQL Server,最后你点击了完成按钮.哇噢~~~现在我们可以把我们的服务器进入生产了!抱歉,那并不是真的,因为你的全新SQL Server默认配置是错误的. 是的,你没看 ...

  5. SpringBoot 配置 Servlet、Filter、Listener

    SpringBoot 配置 Servlet.Filter.Listener 在SpringBoot应用中,嵌入式的 Servlet 3.0+ 容器不会直接使用 ServletContainerInit ...

  6. SQL Server 安装好后 Always On群组配置

    需要对SQL Server必要的端口打开Windows防火墙的入站规则,比如TCP- 1433端口等. 特别注意:由于AG默认需要用到TCP-5022端口,所以该端口务必保证在Windows防火墙中开 ...

  7. SpringBoot初始教程之Servlet、Filter、Listener配置(七)

    1.介绍 通过之前的文章来看,SpringBoot涵盖了很多配置,但是往往一些配置是采用原生的Servlet进行的,但是在SpringBoot中不需要配置web.xml的 因为有可能打包之后是一个ja ...

  8. SpringBoot初始教程之Servlet、Filter、Listener配置

    1.介绍通过之前的文章来看,SpringBoot涵盖了很多配置,但是往往一些配置是采用原生的Servlet进行的,但是在SpringBoot中不需要配置web.xml的 因为有可能打包之后是一个jar ...

  9. SpringBoot初始教程之Servlet、Filter、Listener配置详解

    1.介绍 通过之前的文章来看,SpringBoot涵盖了很多配置,但是往往一些配置是采用原生的Servlet进行的,但是在SpringBoot中不需要配置web.xml的 因为有可能打包之后是一个ja ...

随机推荐

  1. Python 索引迭代

    1.使用enumerate函数 L = ['Adam', 'Lisa', 'Bart', 'Paul'] for index, name in enumerate(L):     print inde ...

  2. 步步为营-17-FileStream-文件加密/解密

    以前使用的File是操作小的文本文件,用的并不常见,FileStream(操作字节),可以操作所有格式的文件,用途较广泛 下面做一个通过文件流给文件加密解密的小软件. using System; us ...

  3. phpstrom破解

    lisence输入 2018/04/09  更新  license server:http://im.js.cn:8888 http://idea.iteblog.com/key.php 2018/0 ...

  4. POJ - 1185 敌兵炮阵

    POJ - 3254 中文题.. 思路:这题可把我恶心坏了,我刚开始的思路其实是正确的... 首先我想开个dp[i][s1][s2]保存到 i行 为止当前行状态为s1,上一行状态为s2 的最大个数,然 ...

  5. Word 如何设置空白页不编码,其他页码连续

    或许 不是最简单的方法: 先假设 空白页前的那部分为“第一部分”,空白页后的那部分为“第二部分”. 首先插入2个“分节符”,  将第一部分.空白页.第二部分分成三节(记得取消每一节的“链接到前一条页眉 ...

  6. android和java以太坊开发区块链应用使用web3j类库

    如何使用web3j为Java应用或Android App增加以太坊区块链支持,教程内容即涉及以太坊中的核心概念,例如账户管理包括账户的创建.钱包创建.交易转账,交易与状态.智能合约开发与交互.过滤器和 ...

  7. symmfony

    安装:http://symfony.cn/docs/book/installation.html 1先检查php版本是否符合你要下载的symfony的最低版本: php -version 系统安装完成 ...

  8. DP-hdu1260

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1260 题目描述: 题目大意:每一个人去电影票买票,有两种买票方法:1.自己单人买:2.与前面的人一起买 ...

  9. python tkinter-容器、子窗体

      Frame f = tkinter.Frame(width=380, height=270, bg='white').pack() LabelFrame f = tkinter.LabelFram ...

  10. hdu 1576 A/B 【扩展欧几里得】【逆元】

    <题目链接> <转载于 >>> > A/B Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)( ...