300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > JSP--从一个jsp页面通过按钮跳转到另一个jsp页面

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

时间:2020-11-16 17:09:13

相关推荐

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

JSP按钮跳转页面的方法

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

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

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

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

<%--Created by IntelliJ IDEA.User: 杨小冥Date: /11/11Time: 18:32To 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: /11/11Time: 18:34To 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页面点击注册按钮就跳转到了注册的页面

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。