概述
注意不要把地址写成main.jsp了,这时还没有携带数据呢,写sevlet中的main
index.jsp
<%--
Created by IntelliJ IDEA.
User: U100926
Date: 2021/12/29
Time: 17:41
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<!-- 运行javaScript不用额外安装包,自带了 -->
<script>window.location.href='main';</script>
<!--方法1-->
<!--2种写法都可以,单双引号都可以,注意不要写成了main.jsp会报空指针异常,此时jsp页面还没有携带参数!要写servlet在地址栏的映射main,如下
@WebServlet("/main")
public class Main extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {.......}
<script>window.location.href='main';</script>
<script>window.location.href="main";</script>
<script>window.location.href='http://localhost:8080/main';</script>
<script>window.location.href='success.jsp';</script>
-->
<!--方法2-->
<!--
<script>setTimeout("location.href='main'", 0);</script>
<script>setTimeout("location.href='error.jsp'", 0);</script>
-->
</body>
</html>
测试用的2个页面
success.jsp
<%--
Created by IntelliJ IDEA.
User: U100926
Date: 2021/12/30
Time: 10:16
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>success</title>
</head>
<body>
jump success
</body>
</html>
error.jsp
<%--
Created by IntelliJ IDEA.
User: U100926
Date: 2021/12/30
Time: 10:20
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>error</title>
</head>
<body>
jump error
</body>
</html>
最后
以上就是含糊草丛为你收集整理的页面从http://localhost:8080自动跳转到指定页面(之前的Web日历)的全部内容,希望文章能够帮你解决页面从http://localhost:8080自动跳转到指定页面(之前的Web日历)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复