栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

用thymeleaf浏览器404问题中之一bug

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用thymeleaf浏览器404问题中之一bug

用thymeleaf-----浏览器404问题
问题:
**HTTP Status 404 – Not Found


Type Status Report
Message /thymeleaf_war_exploded/
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/8.5.31**

分析原因:
首先404 是index.html(或者是index.jsp)文件找不到
接着我们一块捋一捋思路:
启动tomcat服务器,服务器在web下面找index.html
(注意:WEB-INF下面的文件是无法从浏览器中直接访问的,必须经过服务器才能访问到WEB-INF下面的文件)
由于index.html放入WEB-INF中,tomcat只能去servlet中找
服务器先读取配置文件web.xml

找到了问题: /index

        ToindexServlet
        com.servlet.ToindexServlet


        ToindexServlet
        /index

如果配置文件没有问题,就检查servlet中是否有错误。

public class ToindexServlet extends ViewbaseServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("访问到了indexservlet。。。");
        this.processTemplate("index",request,response);
    }
}

很明显servlet 中没有错误。

解决方案:


        ToindexServlet
        com.servlet.ToindexServlet


        ToindexServlet
        /index.html

在web.xml配置文件中的/index.html
可以在重启tomcat时候让服务器放问到index.html
以上就是笔者遇到的404

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/760552.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号