jsp_include.jsp頁面:
<%@ include file="static.html" %>
<% // 靜態包含只是把文件包含進來! %>
<a href="action.jsp">goto two ——></a>
<br>
<!-- 超鏈接轉到action.jsp 文件和動態包含該文件顯示是不同的 -->
this examples show include works!
<br>
<!-- 動態包含文件並傳遞參數 -->
<jsp:include page="action.jsp" flush="true">
<jsp:param name="a1" value="<%=request.getParameter("name") %>"/>
<jsp:param name="a2" value="<%=request.getParameter("password") %>"/>
</jsp:include>>
static.html頁面:
<body>
<form method="post" action="jsp_include.jsp">
<table>
<tr>
<td>please input your name:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>input your password:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="login"></td>
</tr>
</table>
</form>
</body>
action.jsp頁面:
this is a1=<%=request.getParameter("a1") %>
<br>
this is a2=<%=request.getParameter("a2") %>
<br>
<% out.println("hello from action.jsp"); %>
jsp_includ.jsp出錯為:
請各位親們看一下怎麼改才能正常運行!
把request.getParameter("name")和另外一個的雙引號改成單引號即可。