Servlet 工程 web.xml 中的 servlet 和 servlet-mapping 标签

摘录工程的 web.xml 文件片段:



访问顺序为1—>2—>3—>4,其中2和3的值必须相同。

url-pattern 标签中的值是要在浏览器地址栏中输入的 url,上面的/services 这个 url 访问地址为http://localhost:8080/services, url 访问为 servlet-name 中值的 servlet,两个 servlet-name 标签的值必须相同,因为通过 servlet 标签中的 servlet-name 标签映射到 servlet-class 标签中的值,最终访问 servlet-class 标签中的 class。

 

另外,<welcome-file-list>标签用于制定首页,比如你写的项目 地址是 http:localhost:8080/test
里边有页面 index.jsp,
如果要访问这个页面的话你要输入 http:localhost:8080/test/index.jsp
如果在 <welcome-file-list>里指定了index.jsp为首页的话
你只要输入  http:localhost:8080/test 就能直接打开 http:localhost:8080/test/index.jsp

原文地址:https://www.cnblogs.com/lan-writenbook/p/4743560.html