SpringBoot在linux上视图解析问题

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.解决方案

答案—-来自stackoverflow

翻译一下:

也就是return的时候去掉前面的斜杠。
在IDE中运行时,该资源可以直接从文件系统中使用,双斜杠不会导致问题。 当您从jar文件中运行资源时,该资源嵌套在该jar中,双斜线阻止它被发现。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值