226
技術社區[雲棲]
JSP基礎6
<%@ page contentType="text/html; Charset=gb2312" language="java" import="java.util.*" errorPage="" %>
<html>
<head>
<title>JSP練習</title>
</head>
<body>
<form action="b.jsp" method="post" name="frmName">
<font color="black" size="3">
<br>選擇一幅圖像:
<select name="img">
<option value="images/love.jpg" selected>人物</option>
<option value="images/wife.jpg">愛人</option>
<option value="images/xx.jpg">小侄子</option>
</select>
<br>選擇視頻或音樂:
<select name="video">
<option value="a.wmv">茉莉花</option>
<option value="b.wmv">動畫片</option>
<option value="c.wmv">飛翔的鴿子</option>
</select>
<br><input type="submit" value="提交" name="submit">
</font>
</form>
</body>
</html>
<%@ page contentType="text/html; Charset=gb2312"%>
<html>
<head>
<title>Jsp練習</title>
</head>
<%!
public String getGBString(String src){
try{
if (src == null) return null;
else{
src = new String(src.getBytes("ISO-8859-1"), "GBK");
return src;
}
}
catch (Exception e){
return null;
}
}
%>
<body>
<%
String img = request.getParameter("img");
String video = request.getParameter("video");
if (img == null){
img = "images/love.jpg";
}
if (video == null){
video = "a.wmv";
}
%>
<img src="<%=img%>" width="120" height="120">圖像</img>
<embed src="<%=video%>" width="120" height="120">視頻</embed>
</body>
</html>
最後更新:2017-04-02 00:06:49