1,超链接
<!-- 链接到page2 -->
<a href="page2.jsp">链接到page2</a><br>
<!-- 链接到page2,弹出新窗口 -->
<a href="page2.jsp" target="_blank">链接到page2</a><br>
<!-- 相对路径链接到page2 -->
<a href="./page2.jsp">链接到page2</a><br>
<a href="../demo1/page2.jsp">链接到page2</a><br>
<!-- 绝对路径链接到page2 -->
<a href="http://localhost:8080/web2/demo1/page2.jsp">链接到page2</a><br>
<a href="<%=request.getContextPath() %>/demo1/page2.jsp">链接到page2</a><br>
<!-- 链接到page2,并传参 -->
<a href="page2.jsp?uid=admin">链接到page2</a><br>
2,超链接+JS
<!-- 使用js链接到page2 -->
<a href=‘javascript:fun();‘>链接到page2</a><br>
<!-- 使用js链接到page2,并传参 -->
<a href=‘javascript:fun();‘>链接到page2</a><br>
<script type="text/javascript">
function fun(){
//window.location="page2.jsp?uid=admin";
window.open("page2.jsp?uid=admin");
}
</script>
<!-- 使用js链接到page2,弹出新窗口,并传参 -->
<a href=‘javascript:fun();‘>链接到page2</a><br>
3,submit提交表单
<!-- submit提交表单 -->
<form action="page2.jsp" method="post">
<input type="text" name="uid"><input type="submit" value="提交表单">
</form>
<!-- 验证后提交表单 -->
<form action="page2.jsp" method="post">
<input type="text" name="uid" id="uid">
<input type="submit" value="提交表单" onclick="return fun2();">
</form>
<script type="text/javascript">
function fun2(){
var uid = document.getElementById("uid").value;
if(uid == ""){
alert("请输入用户名");
return false;
} else{
return true;
}
}
</script>
<!-- url方式提交数据 -->
<form action="page2.jsp?uid=admin" method="post">
<input type="submit" value="提交表单">
</form>
<!-- hidden方式提交数据 -->
<form action="page2.jsp" method="post">
<input type="hidden" name="uid" id="uid2" value="admin">
<input type="submit" value="提交表单">
<script type="text/javascript">
document.getElementById("uid2").value="admin2";
</script>
</form>
4,JS
<!-- button+js提交表单 -->
<form id="form1" action="page2.jsp" method="post">
<input type="text" name="uid">
<input type="button" value="提交表单" onclick=‘document.getElementById("form1").submit();‘>
</form>
<!-- <a>+js提交表单 -->
<form id="form2" action="page2.jsp" method="post">
<input type="text" name="uid">
<a href=‘javascript:document.getElementById("form2").submit();‘>提交表单</a>
</form>