1 . 頁面初始化
2 . 取得對應標籤參數
3 . 點擊事件
4 . Form 傳送資料,另一頁面接收( Jsp、Struts2 )
頁面初始化
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
});
</script>
<body>
</body>
</html>
取得對應標籤參數
<script>
.
var age = document.getElementById("editText").value;
.
</script>
<body>
.
<input type="text" id="editText" value="" />
.
</body>
點擊事件
<script>
function myFunction() {
.
.
.
}
</script>
<body>
<input type="button" id="btn" value="送出" onclick="myFunction()" />
</body>
</html>
Form 傳送資料,另一頁面接收( Jsp、Struts2 )
參考資料:How to pass the values from one jsp page to another jsp without submit button?
a.jsp
<form action="hello_4" method="post">
<input type="text" name="name">
<input type="submit" name="send">
</form>
b.jsp
<body>
<% String name=request.getParameter("name"); out.print("Hello:"+name); %>
</body>
沒有留言:
張貼留言