spring boot 对输入的页面去掉后缀的配置

1.在application.properties文件中添加
spring.thymeleaf.prefix=classpath:/static/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
#spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf.content-type=text/html # ;charset=<encoding> is added
spring.thymeleaf.cache=false


2.在WebMvcConfigurerAdapter中设置相应内容
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		registry.addViewController("/ws").setViewName("/ws");
	}
}


3.引入依赖包
<dependency>
	    <groupId>net.sourceforge.nekohtml</groupId>
		<artifactId>nekohtml</artifactId>
		<version>1.9.22</version>
	</dependency>



猜你喜欢

转载自forlan.iteye.com/blog/2400444