JSP–从一个jsp页面通过按钮跳转到另一个jsp页面

JSP–从一个jsp页面通过按钮跳转到另一个jsp页面JSP按钮跳转页面的方法一句代码实现jsp页面跳转!在初始的index.jsp页面中,给按钮添加一个点击事件(onclick)οnclick=”window.location.href=‘register.jsp’;”通过单引号引住的部分是我们要跳转到的那个jsp页面<%CreatedbyIntelliJIDEA.User:杨小冥Date:2020/11/11Time:18:32TochangethistemplateuseFile|

大家好,欢迎来到IT知识分享网。

JSP按钮跳转页面的方法

一句代码实现jsp页面跳转!

在初始的index.jsp页面中,给按钮添加一个点击事件(onclick)

οnclick=”window.location.href=‘register.jsp’;”

通过单引号引住的部分是我们要跳转到的那个jsp页面

<%--
  Created by IntelliJ IDEA.
  User: 杨小冥
  Date: 2020/11/11
  Time: 18:32
  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>
    <form action="/login" method="post">
      账号<input type="text" name="username"/><br>
      密码<input type="password" name="password"/><br>
      <input type="submit" value="登录"/>
    </form>
    <input type="button" onclick="window.location.href='register.jsp';" value="注册VIP">
  </body>
</html>

在这里插入图片描述
还有一个注册页面(register.jsp)

<%--
  Created by IntelliJ IDEA.
  User: 杨小冥
  Date: 2020/11/11
  Time: 18:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>register</title>
</head>
<body>
    <h1>欢迎注册xxxVIP</h1>
    <form action="/toregister" method="post">
        账号<input type="text" name="username"/><br>
        密码<input type="password" name="password"/><br>
        <input type="submit" value="注册"/>
    </form>
</body>
</html>

在index页面点击注册按钮就跳转到了注册的页面
在这里插入图片描述

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/15944.html

(0)

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信