⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 distrbypostsdepservlet.java

📁 jsp+servlet+Hibernte实现的公务员网上报名系统。为大学毕业设计成果
💻 JAVA
字号:
package com.servlet;

import java.io.IOException;

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

import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.general.DefaultPieDataset;

import com.service.DistributionByPostsDepService;
import com.service.impl.DistributionByPostsDepServiceImpl;

public class DistrByPostsDepServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public DistrByPostsDepServlet() {
		super();
	}

	public void destroy() {
		super.destroy(); 
	}

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

		doPost(request,response);
	}

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

		request.setCharacterEncoding("gb2312");
		response.setCharacterEncoding("gb2312");
		String postsDep = request.getParameter("postsDep");
		
		DistributionByPostsDepService distributionByPostsDepServiceImpl = new DistributionByPostsDepServiceImpl();
		distributionByPostsDepServiceImpl.CountAppBENByPostsDep(postsDep);
		int benCount = distributionByPostsDepServiceImpl.CountAppBENByPostsDep(postsDep);
	    int zhuanCount = distributionByPostsDepServiceImpl.CountAppZHUANByPostsDep(postsDep);
	    int shuoCount = distributionByPostsDepServiceImpl.CountAppSHUOByPostsDep(postsDep);
	    int boCount = distributionByPostsDepServiceImpl.CountAppBOByPostsDep(postsDep);
	    int menCount = distributionByPostsDepServiceImpl.CountAppMenByPostsDep(postsDep);
	    int womenCount = distributionByPostsDepServiceImpl.CountAppWomenByPostsDep(postsDep);
		 
		DefaultPieDataset data = new DefaultPieDataset(); 
        data.setValue("专科",zhuanCount); 
        data.setValue("学士",benCount); 
        data.setValue("硕士",shuoCount); 
        data.setValue("博士",boCount); 
      
        HttpSession session = request.getSession();
        PiePlot3D plot = new PiePlot3D(data);//生成一个3D饼图 
        JFreeChart chart = new JFreeChart("",JFreeChart.DEFAULT_TITLE_FONT, plot, true); 
        chart.setBackgroundPaint(java.awt.Color.white);//可选,设置图片背景色 
        chart.setTitle("学历比例情况");//可选,设置图片标题 
        StandardEntityCollection sec = new StandardEntityCollection(); 
        ChartRenderingInfo info = new ChartRenderingInfo(sec); 
        String filename = ServletUtilities.saveChartAsJPEG(chart,500,300,info,session); 
        String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;        
        request.setAttribute("graphURL", graphURL);
        
        DefaultPieDataset dataSex = new DefaultPieDataset(); 
        dataSex.setValue("男性",menCount); 
        dataSex.setValue("女性",womenCount); 
      
        HttpSession sessionSex = request.getSession();
        PiePlot3D plotSex = new PiePlot3D(dataSex);//生成一个3D饼图 
        JFreeChart chartSex = new JFreeChart("",JFreeChart.DEFAULT_TITLE_FONT, plotSex, true); 
        chartSex.setBackgroundPaint(java.awt.Color.white);//可选,设置图片背景色 
        chartSex.setTitle("性别比例情况");//可选,设置图片标题 
        StandardEntityCollection secSex = new StandardEntityCollection(); 
        ChartRenderingInfo infoSex = new ChartRenderingInfo(secSex); 
        String filenameSex = ServletUtilities.saveChartAsJPEG(chartSex,500,300,infoSex,sessionSex); 
        String graphURLSex = request.getContextPath() + "/servlet/DisplayChart?filename=" + filenameSex;        
        request.setAttribute("graphURLSex", graphURLSex);
        
        request.getRequestDispatcher("/form/distr_byPostsDep.jsp").forward(request, response);
	}

	public void init() throws ServletException {
		
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -