Java 如何使Eclipse提供默认的servlet url?

Java 如何使Eclipse提供默认的servlet url?,java,servlets,Java,Servlets,我的servlet代码中有这一行(在动态web项目中): 但当我右键点击这个项目,runas,runonserver时,它就启动了 http://localhost:8090/LoginServletApp/ 结果是404。我必须手动将url更改为 http://localhost:8090/LoginServletApp/login 如何在默认情况下提供此url(即以“/登录”结尾)?我环顾了一下,提到了一个名为web.xml的文件,它可以在每个项目的基础上创建,但这似乎适用于物理文件;我

我的servlet代码中有这一行(在动态web项目中):

但当我右键点击这个项目,runas,runonserver时,它就启动了

http://localhost:8090/LoginServletApp/
结果是404。我必须手动将url更改为

http://localhost:8090/LoginServletApp/login
如何在默认情况下提供此url(即以“/登录”结尾)?我环顾了一下,提到了一个名为web.xml的文件,它可以在每个项目的基础上创建,但这似乎适用于物理文件;我要求eclipse生成一个部署描述符,它为我创建了这个文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
  <display-name>LoginServletApp</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

LoginServletApp
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
提前谢谢你,如果以前有人问过这个问题(可能有,但我找不到,也找不到解决办法),我表示歉意

编辑:我在web.xml文件中添加了以下行,但正如预期的那样,它不起作用:

<welcome-file>login.html</welcome-file>
login.html

根据欢迎文件列表中的条目,容器按顺序查找文件。因此,如果您将登录名作为first添加到列表中,它将首先提供,您将不会得到404

<welcome-file-list>
    <welcome-file>login</welcome-file>
    ..
</welcome-file-list>

登录
..

根据欢迎文件列表中的条目,容器按顺序查找文件。因此,如果您将登录名作为first添加到列表中,它将首先提供,您将不会得到404

<welcome-file-list>
    <welcome-file>login</welcome-file>
    ..
</welcome-file-list>

登录
..

嗨,很好用,非常感谢。我不得不重新启动服务器(由于某种原因,没有重新启动它),但现在它可以工作了。就这么简单。谢谢。嗨,那很有效,非常感谢。我不得不重新启动服务器(由于某种原因,没有重新启动它),但现在它可以工作了。就这么简单。谢谢