SpringBoot打成jar包时访问templates下的html出错或访问不到
问题描述
- 背景
- 在Springboot项目中,本地环境下(idea)中,访问html文件的方式如图结构
- 在Springboot项目中,本地环境下(idea)中,访问html文件的方式如图结构
- 问题
- 打成jar包再次访问时,报错
This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Mar 06 12:04:46 CST 2019 There was an unexpected error (type=Internal Server Error, status=500). Error resolving template "/login", template might not exist or might not be accessible by any of the configured Template Resolvers
- 打成jar包再次访问时,报错
解决
-
将页面跳转控制类的路径做修改
@RequestMapping("/{pagename}") public String toPage(HttpServletRequest request, @PathVariable("pagename") String pagename) { //return "/" + pagename;//idea环境下这样写的 return pagename;//打jar包时应该这样写 }