【发布时间】:2016-06-24 02:30:01
【问题描述】:
我使用 Intellij IDEA 用 tomcat 7.0.64 创建了一个简单的 WebApplication。
我在 IDEA 中运行 tomcat,然后http://localhost:8080/ 可以正常工作,显示 index.jsp。然后我可以附加 xxx.jsp 以转到该页面。 但如果我想转到 .html 页面,那将是 404 错误:
如果我在浏览器中打开 .html 文件,它可以正常工作并显示内容。
在我更改了 index.jsp 的名称后(所以我猜 index.html 将是门),问题仍然存在。
编辑:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
实际上什么都没有,因为项目什么都没有生成,我不知道应该配置什么属性。
【问题讨论】:
-
向我们展示您的
web.xml文件。index.html的请求很可能被拦截了。 -
您没有提供正确的 url 来午餐那个 html 文件尝试类似 localhost:8080/html/index.html 或直接从 intellij 运行文件
-
@PacMan 呃......这很奇怪。我在询问之前已经这样做了,当时我无法访问 localhost:8080/html/index.html ,但现在它似乎工作了。无论如何谢谢!
-
@PacMan 现在我不确定 index.html 是否在 tomcat 中打开。我怎样才能让tomcat的门成为index.html(就像之前的index.jsp一样)所以我可以运行tomcat并显示。
-
你检查过tomcat日志吗?
标签: java html jsp tomcat intellij-idea