Java EE实现直接进入登录界面-JS页面跳转(一)

来源:互联网 发布:jenkins 本机部署php 编辑:程序博客网 时间:2024/06/07 05:41

Java EE实现直接进入登录界面-JS页面跳转(一)

引子:
后台登录界面,一打开链接,就需要跳转到login.jsp这个界面,进行登录。而我们知道在Java项目中,默认是直接跳转到index.jsp这个界面的。那么怎么样才能直接指定页面跳转到登录界面呢。

分析:
1、直接从web.xml中配置,直接跳转到login.jsp登录界面。
2、从index.jsp界面进行JS跳转。

实现:
方法一:
web.xml配置文件中,直接设置<welcom file list>,指定<welcome-file>login.jsp
代码如下:(PS:切记,在web.xml配置文件中)

<welcome-file-list>    <welcome-file>login.html</welcome-file>    <welcome-file>login.htm</welcome-file>    <welcome-file>login.jsp</welcome-file></welcome-file-list>

方法二:
index.jsp设置界面进行JS跳转。
代码如下:(PS:切记,在web.xml配置文件中,指定<welcome-file>index.html</welcome-file>,或者不指定<welcome-file>

//在**index.jsp**文件中<body>    <!-- 自动跳转 跳转到后台登录界面 -->    <script language="JavaScript">       window.location.href = "login";    </script></body>
1 0
原创粉丝点击