日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Java制作投票系統(tǒng)代碼

這篇文章主要為大家詳細(xì)介紹了Java制作投票系統(tǒng),文中示例代碼介紹的非常詳細(xì),零基礎(chǔ)也能參考此文章,感興趣的小伙伴們可以參考一下。

創(chuàng)新互聯(lián)建站是一家專業(yè)提供梁子湖企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計、成都做網(wǎng)站、H5響應(yīng)式網(wǎng)站、小程序制作等業(yè)務(wù)。10年已為梁子湖眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計公司優(yōu)惠進(jìn)行中。

代碼展示:

package com.tarena.wgh.servlet;

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

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

public class PollServlet extends HttpServlet {

/**

* The doPost method of the servlet.
* * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response)        throws ServletException, IOException {    request.setCharacterEncoding("GBK");    //設(shè)置請求的編碼方式    String item=request.getParameter("item");   //獲取投票項    ServletContext servletContext=request.getSession().getServletContext(); //獲取ServletContext對象該對象在application范圍內(nèi)有效    Map map=null;    if(servletContext.getAttribute("pollResult")!=null){        map=(Map)servletContext.getAttribute("pollResult"); //獲取投票結(jié)果        map.put(item,Integer.parseInt(map.get(item).toString())+1); //將當(dāng)前的投票項加1    }else{      //初始化一個保存投票信息的Map集合,并將選定投票項的投票數(shù)設(shè)置為1,其他為0        String[] arr={"基礎(chǔ)教程類","實例集錦類","經(jīng)驗技巧類","速查手冊類","案例剖析類"};        map=new HashMap();        for(int i=0;i}

關(guān)于Java制作投票系統(tǒng)就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果喜歡這篇文章,不如把它分享出去讓更多的人看到。


網(wǎng)站欄目:Java制作投票系統(tǒng)代碼
URL鏈接:http://www.dlmjj.cn/article/pighhg.html