2013年9月10日 星期二

JSP:表單製作(簡單傳送字串)

新增兩個檔案 input.jsp、display.jsp, 要注意method參數get、post。
(post:若有要傳送圖片或檔案,請使用這個參數。)

input.jsp
<body>
<form action="display.jsp" method="post">
<input type="text" id="username" name="username"/>
<input type="submit" />
</form>
</body>
-----------------------------------------------------------------------------------
display.jsp
<body>
<%
request.setCharacterEncoding("utf-8");
String strname="";
strname=request.getParameter("username");
out.println("你的姓名為:"+strname);
%>
</body>



沒有留言:

張貼留言