1、jsp中,一个button onclick跳转
方式一:οnclick="window.location='new.jsp'"。
οnclick="openpage()"
方式二:
<script type="text/JavaScript">
function openpage(){
window.location.replace("/new.jsp");
}
</script>
方式三:
<script type="text/javascript">
function openpage(){
window.location = "/new.jsp";
}
</script>
方式四:
<script type="text/javascript">
function openpage(){
window.location.href="/new.jsp"
}
</script>
Demo
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SpringBoot测试界面</title>
<script type="text/javascript">
function out()
{
var name = 'sxw';
alert('MyName:' + name);
}
</script>
</head>
<body>
<center>
<input οnclick="out()" type="button" value="测试" >
<input type="button" οnclick="javascript:window.location='http://127.0.0.1:8080/sxw1'" value="URL跳转" >
</center>
</body>
</html>