隨筆 - 15, 文章 - 0, 評論 - 5, 引用 - 0

          導航

          <2008年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(2)

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          處理隱藏表單的方法

          實例名稱:  滿意度調查表


          HTML頁面代碼

          <html>
          <head>
          <title> 網站使用滿意度調查 </title>
          <meta http-equiv="content-type" content="text/html; charset=UTF-8">
          </head>
          <body>

          <form method="post" action="/webproject1/servlet/loginlorm1">
          <input type="hidden" name="survey_type" value="滿意度調查">
          <table border="0">
           <tr>
            <td align="right">您對本網站提供的所有服務滿意嗎?</td> 
           </tr>
            <tr>
             <td>
             <input type="submit" name="attitude" value="滿意">
             <input type="submit" name="attitude" value="不滿意">
              </td>
            </tr>
          </table>
          </form>
          </body>
          </html>


          servlet中的代碼

          package com.v503.zhouzhou;

          import java.io.IOException;
          import java.io.PrintWriter;
          import java.util.Enumeration;

          import javax.servlet.ServletException;
          import javax.servlet.http.HttpServlet;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          @SuppressWarnings("serial")
          public class LoginForm1 extends HttpServlet {

           public void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {

                            doPost(request,response);
           }


           @SuppressWarnings("unchecked")
           public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
            response.setContentType("text/html;charset=utf-8");
            PrintWriter out = response.getWriter();
            out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
            request.setCharacterEncoding("utf-8");
            out.println("<HTML>");
            out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
            out.println("  <BODY>");
           // 處理方法
            @SuppressWarnings("unused")
            Enumeration  e=request.getParameterNames();
            @SuppressWarnings("unused")
            String parameter=null;
            while(e.hasMoreElements()){
             parameter=(String)e.nextElement();
             @SuppressWarnings("unused")
             String value[]=request.getParameterValues(parameter);
             out.println(parameter+"<br>");
             out.println("<ul>");
            for(int i=0;i<value.length;i++)
            out.println("<li>"+value[i]+"</li>"); 
            out.println("</ul>"); 
            }

            out.println("  </BODY>");
            out.println("</HTML>");
            out.flush();
            out.close();
           }
           public String filterHtml(String value){
            value=value.replaceAll("&","&amp");
            value=value.replaceAll("<", "&lt;");
            value=value.replaceAll(">", "&gt;");
            value=value.replaceAll(" ","&nbsp;");
            value=value.replaceAll("'","value39;");
            value=value.replaceAll("\"","value;");
            value=value.replaceAll("\n", "value");
            return value;
           }

          }





          posted on 2008-07-29 21:22 zhouzhou@ 閱讀(553) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 新丰县| 平安县| 滦南县| 方城县| 尼木县| 临沂市| 巴林右旗| 广汉市| 和静县| 苍南县| 通河县| 来凤县| 祁东县| 英山县| 濮阳市| 虞城县| 桐柏县| 额尔古纳市| 伊川县| 黑山县| 山阴县| 遵义县| 黎川县| 新民市| 三原县| 阳新县| 乌兰浩特市| 柞水县| 邹平县| 布尔津县| 德庆县| 城步| 新郑市| 若尔盖县| 明星| 安庆市| 禹州市| 鄂州市| 宾阳县| 韶关市| 项城市|