阅读226 返回首页    go 阿里云 go 技术社区[云栖]


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

  上一篇:go Android开发7——android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1
  下一篇:go JSP基础1