<%@ 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>
时间: 2024-12-24 09:55:36