繁体   English   中英

为什么在带有DD的Web项目中找不到index.jsp

[英]Why can not find the index.jsp in the web project with DD

所有人,请原谅我是Java Web世界的新手,我正在尝试编写一个Web项目进行测试。 但似乎我没有得到我期望的结果。 我不知道会发生什么。 请帮忙复习一下。这是我到目前为止所做的。

  1. 在Eclipse中使用选项Generate web.xml DD创建一个名为MyFirstWeb的动态Web项目。
  2. WebContent目录下添加index.jsp下面是其中的页面代码。
 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>My Title</title> </head> <body> <% java.util.Date d = new java.util.Date(); %> <h1> Today's date is <%= d.toString() %> and this jsp page worked! </h1> </body> </html> 

在将它发布到Eclipse中的内置Tomcat服务器运行时之后。 启动服务器时没有错误。 但是我的URL为http://localhost:8080/MyFirstWeb/index.jsp一个空白页,为什么? 谢谢。

添加到您的web.xml

<welcome-file-list>
   <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

好吧,我在Eclipse中使用了您的确切代码,并且运行良好。 您可以发布错误消息吗? 并检查您的web.xml是否具有此

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>MyFirstWeb</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM