package com.jwy.action;
import java.awt.Color;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.jwy.dao.ICourseDao;
import com.jwy.dao.ISpecialtyDao;
import com.jwy.dto.Course;
import com.jwy.dto.Specialty;
import com.jwy.dto.StuUser;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class StatInfoAction extends DispatchAction {
private ISpecialtyDao specialtyDao;
private ICourseDao courseDao;
/**
* @param specialtyDao
* the specialtyDao to set
*/
public void setSpecialtyDao(ISpecialtyDao specialtyDao) {
this.specialtyDao = specialtyDao;
}
/**
* @param courseDao
* the courseDao to set
*/
public void setCourseDao(ICourseDao courseDao) {
this.courseDao = courseDao;
}
/**
* 按照专业编号,课程名称,授课教师姓名进行搜索
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward findBySearch(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<Specialty> sList = specialtyDao.findByAll();
Map<String, String> map = new HashMap<String, String>();
if (request.getParameter("specialtyId") != null
&& !request.getParameter("specialtyId").equals("-1")) {
map.put("specialtyId", request.getParameter("specialtyId"));
}
if (request.getParameter("name") != null
&& !request.getParameter("name").equals("")) {
map.put("name", request.getParameter("name"));
}
if (request.getParameter("teacherName") != null
&& !request.getParameter("teacherName").equals("")) {
map.put("teacherName", request.getParameter("teacherName"));
}
List<Object[]> clist = courseDao.findByStat(map);
request.setAttribute("sList", sList);
request.setAttribute("cList", clist);
return mapping.findForward("showStat");
}
/**
* 跟据课程编号查询选择该门课程的学生
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward stuList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer specialtyId = Integer.valueOf(request
.getParameter("specialtyId"));
Specialty specialty = specialtyDao.findById(specialtyId);// 专业信息
Integer courseId = Integer.valueOf(request.getParameter("courseId"));
List<Object[]> list = courseDao.findSelectStu(courseId);
Course course = courseDao.findByID(courseId);
System.out.println(courseId);
request.setAttribute("specialty", specialty);
request.setAttribute("stuList", list);
request.setAttribute("course", course);
return mapping.findForward("stuList");
}
/**
* 将上课学生名单导出PDF文档
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward exPDF(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Integer specialtyId = Integer.valueOf(request.getParameter("specialtyId"));
Specialty specialty = specialtyDao.findById(specialtyId);// 专业信息
Integer courseId = Integer.valueOf(request.getParameter("courseId"));
List<Object[]> list = courseDao.findSelectStu(courseId);
Course course = courseDao.findByID(courseId);
response.setContentType("text/html;charset=GBK");
response.setContentType("application/xml");
response.setHeader("Content-Disposition", "attachment;filename="
+ new String(course.getName().getBytes(), "iso-8859-1")+".pdf");
OutputStream outs = response.getOutputStream(); // 获取输出流
Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, outs);
document.open();
// 设置中文字体
BaseFont bfChinese = BaseFont.createFont("STSong-Light",
"UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font t1 = new Font(bfChinese, 20, Font.BOLD); // 设置一级标题字体
Font t2 = new Font(bfChinese, 15, Font.BOLD); // 设置二级标题字体
Font f1 = new Font(bfChinese, 12, Font.NORMAL); // 设置正文字体
Paragraph pragraph = new Paragraph(
specialty.getEnterYear() + "届" + specialty.getLangthYear()
+ "年制" + specialty.getName() + "专业", t1);
pragraph.setAlignment(Paragraph.ALIGN_CENTER);
document.add(pragraph);
pragraph = new Paragraph(course.getName() + "课程听课人员名单"+" 听课总人数:"+list.size()+" 人", t2);
pragraph.setAlignment(Paragraph.ALIGN_CENTER);
document.add(pragraph);
pragraph = new Paragraph("授课教师" + course.getTeacherName(), t2);
pragraph.setAlignment(Paragraph.ALIGN_CENTER);
document.add(pragraph);
// 建立一个表格
PdfPTable table = new PdfPTable(4);
table.setSpacingBefore(40f);// 设置表格上面空白宽度
// 生成表头
String[] bt = new String[] { "学生姓名", "学号", "性别", "联系电话" };
for (int i = 0; i < bt.length; i++) {
PdfPCell cell = new PdfPCell(new Paragraph(bt[i], f1)); // 建立一个单元格
cell.setBackgroundColor(Color.GRAY);
cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 设置内容水平居中显示
cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 设置垂直居中
table.addCell(cell);
}
for (int i = 0; i < list.size(); i++) {
Object[] o = list.get(i);
StuUser stuUser = (StuUser) o[0];
PdfPCell nameCell = new PdfPCell(new Paragraph(stuUser.getStuName(), f1)); // 建立一个单元格
nameCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 设置内容水平居中显示
nameCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 设置垂直居中
PdfPCell stuNoCell = new PdfPCell(new Paragraph(stuUser.getStuNo(),f1)); // 建立一个单元格
stuNoCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 设置内容水平居中显示
stuNoCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 设置垂直居中
PdfPCell stuSexCell = new PdfPCell(new Paragraph(stuUser.getStuSex(), f1)); // 建立一个单元格
stuSexCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 设置内容水平居中显示
stuSexCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 设置垂直居中
PdfPCell telCell = new PdfPCell(new Paragraph(stuUser.getTel(), f1)); // 建立一个单元格
telCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 设置内容水平居中显示
telCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 设置垂直居中
table.addCell(nameCell);
table.addCell(stuNoCell);
table.addCell(stuSexCell);
table.addCell(telCell);
}
document.add(table);
document.close();
outs.close();
return null;
}
/**
* 将上课学生信息导出为Excel文档
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward exExcel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {
Integer specialtyId = Integer.valueOf(request.getParameter("specialtyId"));
Specialty specialty = specialtyDao.findById(specia
该高校学生选课系统是基于Java编程语言进行开发的,主要应用于课程设计和毕业设计实践。这个项目提供了完整的源码,对于学习Java编程、理解Web应用程序开发流程以及深入探究学生选课系统的运作机制有着重要的参考价值。下面我们将详细讨论这个项目涉及的知识点。 1. **Java编程基础**:作为项目的基石,Java是一种面向对象的编程语言,以其平台独立性和丰富的类库受到广泛欢迎。在这个系统中,Java用于编写业务逻辑、数据处理和用户交互等核心模块。 2. **MVC设计模式**:通常在Web应用开发中,Model-View-Controller(MVC)模式被广泛应用。模型负责数据处理和业务逻辑,视图负责展示数据,控制器协调模型和视图的交互。学生选课系统可能采用这种架构,以提高代码的可维护性和可扩展性。 3. **Servlet与JSP**:在Java Web开发中,Servlet用于接收和响应HTTP请求,而JSP(JavaServer Pages)则用于生成动态网页内容。这两个技术常结合使用,实现后端与前端的交互。 4. **JDBC与数据库操作**:为了存储和管理学生的选课信息,系统很可能使用了JDBC(Java Database Connectivity)接口来连接和操作数据库,如MySQL或Oracle。开发者可能编写了SQL语句来执行数据的增删改查操作。 5. **Web容器**:项目运行需要一个Web服务器或容器,如Tomcat,它能够解析并执行Servlet,为Java Web应用提供运行环境。 6. **Eclipse或IntelliJ IDEA开发环境**:`.classpath`、`.settings`、`.mymetadata`、`.project`等文件可能是由这些集成开发环境(IDE)生成的配置文件,它们帮助开发者管理和构建项目。 7. **WebRoot目录**:这是Web应用的根目录,通常包含HTML、CSS、JavaScript、图片等静态资源,以及Servlet和JSP文件。 8. **程序使用说明.doc**:这份文档详细解释了如何运行和使用该系统,包括环境配置、部署步骤和功能介绍,对于理解和调试源码非常有帮助。 9. **版本控制与协作**:虽然未明确提及,但项目可能使用了Git或其他版本控制系统来管理代码,以便团队协作和版本追踪。 10. **测试与调试**:在开发过程中,单元测试和集成测试必不可少,确保各个组件的功能正确性。JUnit可能是用于进行单元测试的工具。 通过研究这个项目,学习者可以了解Java Web应用的开发全过程,包括数据库设计、前后端交互、错误处理和性能优化等方面,对于提升Java编程和软件工程能力大有裨益。同时,这样的项目也是实际工作中的宝贵参考资料。

























































































































- 1
- 2

- #完美解决问题
- #运行顺畅
- #内容详尽
- #全网独家
- #注释完整

- 粉丝: 1334
- 资源: 1050
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 非线性与线性MPC路径规划跟踪控制:自动驾驶的nmpc与simulink联合仿真实践,非线性与线性MPC路径规划跟踪控制研究:基于Matlab与Simulink的自动驾驶联合仿真探索,自动驾驶规划控制
- 车辆三自由度动力学MPC跟踪双移线仿真研究:Matlab与Simulink联合应用,车辆三自由度动力学MPC跟踪双移线仿真研究:Matlab与Simulink联合应用,自动驾驶控制-车辆三自由度动力学
- 分布式驱动汽车稳定性控制的分层式直接横摆力矩控制策略研究,基于分布式驱动的汽车稳定性控制技术研究-采用分层式直接横摆力矩控制的滑模优化算法,分布式驱动汽车稳定性控制 采用分层式直接横摆力矩控制,上
- 海康四相机测量项目源码解析:通俗易懂学习范例,含C#+halcon模板匹配与多种测量模式,海康四相机测量项目源码解析:C#+halcon实现模板匹配、圆形与直线拟合等功能的范例,四相机测量项目源码,海
- 石墨烯钙钛矿太阳能电池COMSOL仿真研究:光电热耦合模型的探索与实践,石墨烯钙钛矿太阳能电池COMSOL仿真:光电热耦合模型研究与应用探索,石墨烯 钙钛矿太阳能电池COMSOL仿真:光电热耦合模型
- 分布式电源选址定容优化与多目标寻优PSO算法的Matlab程序实现:以网损、电压偏差和光伏消纳为目标函数的配电网分布式光伏电源优化配置研究,分布式电源选址定容优化与多目标寻优的PSO算法MATLAB程
- 基于Matlab的BoostPFC闭环CRM开关电源模型:仿真、学习与交流的优质资源,BoostPFC闭环CRM开关电源模型:MATLAB仿真入门指南及文献参考,BoostPFC闭环CRM开关电源模型
- 基于ADRC的非线性主动悬架控制技术:设计观测器与误差反馈控制器的实践与效果评估,基于ADRC的主动悬架控制技术:设计观测器与非线性误差反馈控制器的实践研究,基于ADRC的主动悬架控制: 1.设计观测
- 基于基波分析法的双向CLLLC谐振变换器:电压增益与品质因数Q及电感比k关系的可视化研究,双向CLLLC谐振变换器基波分析:电压增益与品质因数Q及电感比k的关联性研究-基于MATLAB仿真实验的探索
- 基于MATLAB与Simulink联合仿真验证的魔术轮胎模型侧偏力对比研究,Matlab与Simulink联合仿真验证魔术轮胎模型侧偏力对比研究,魔术轮胎公式验证 matlab与simulink联合仿
- 车辆二自由度动力学模型验证:MATLAB与Simulink联合仿真与Carsim对比分析,车辆二自由度动力学模型验证:MATLAB与Simulink联合仿真与Carsim对比分析,车辆二自由度动力学模
- 车辆运动学模型的验证:Matlab与Simulink联合仿真与Carsim输出对比研究,车辆运动学模型的验证:Matlab与Simulink联合仿真与Carsim输出对比分析,车辆运动学模型验证 ma
- 直齿轮故障时变啮合刚度求解及Matlab程序实现:点蚀与剥落故障下的齿轮动力学研究,直齿轮点蚀与剥落故障时变啮合刚度求解及其Matlab程序实现:齿轮动力学问题的解析与应用,直齿轮点蚀故障,剥落故障时
- 自动驾驶轨迹跟踪控制:纵向MPC与横向LQR模型,精准跟踪五次多项式换道轨迹,多种转向模型优惠打包,控制效果卓越,自动驾驶轨迹跟踪控制:前轮转向与四轮转向模型打包,精准轨迹跟踪实现MPC纵向控制配合L
- LabWindows CVI上位机与RTX64实时系统下位机共享内存通讯,支持TDMS数据存储与处理,精确至毫秒级控制周期,LabWindows CVI上位机与RTX64实时系统下位机共享内存通讯,支
- 基于IPSO优化LSTM模型的二分类与多分类效果图展示及数据替换指南,基于IPSO优化LSTM模型的二分类与多分类效果展示:非线性权重递减的PSO算法在Matlab中的实现与应用,基于改进的粒子群IP


