java的Web项目如何设置欢迎页面

来源:互联网 发布:大数据数据库 编辑:程序博客网 时间:2024/06/18 01:34

java的Web项目如何设置欢迎页面


    java后台启动成功后可以设置启动成功后,

访问http://localhostL8080 跳转到欢迎页面;


  实现原理:

  前端发送http://localhostL8080到服务端,服务端根据web.xml中的

  welcome-file-list中的welcome-file属性在WebRoot(eclipse)或Webapp(idea)

  目录下查找到welcome-file配置的文件,如果有则将页面返回给前端,如果没有,

  则返回404给前端。


  实现原理图:

 


  实现效果:

 



  实现代码:

    WebRoot(eclipse)或Webapp(idea)中创建 index.html:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title></head><body>    <div>        hello welcome    </div></body></html>


     web.xml:


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






    

阅读全文
0 0
原创粉丝点击