1问题描述
现在有个thymeleaf写的排行榜页面,路径是localhost/rank
在window下能够正常访问,但是部署到linux上只能访问首页,访问不了排行榜页面
还需要什么代码的话我再贴上来。
2.错误页面代码
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Sep 25 23:34:37 CST 2017
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template "/front/rank", template might not exist or might not be accessible by any of the configured Template Resolvers
3.控制带错误代码
2017-09-25 23:34:37.846 ERROR 10643 --- [p-nio-80-exec-3] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-80-exec-3] Exception processing template "/front/rank": Error resolving template "/front/rank", template might not exist or might not be accessible by any of the configured Template Resolvers
2017-09-25 23:34:37.855 ERROR 10643 --- [p-nio-80-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/front/rank", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
...省略
4.控制器
@Controller
public class FrontController {
@RequestMapping(value = "/",method = RequestMethod.GET)
public String index(){
return "index";
}
@RequestMapping(value = "/rank",method = RequestMethod.GET)
public String rank(){
return "/front/rank";
}
}
5.目录结构
6.解决方案
翻译一下:
也就是return的时候去掉前面的斜杠。
在IDE中运行时,该资源可以直接从文件系统中使用,双斜杠不会导致问题。 当您从jar文件中运行资源时,该资源嵌套在该jar中,双斜线阻止它被发现。