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(special
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
高校选课系统 strcts2 spring <%@ page language="java" pageEncoding="GBK"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <html> <head> <title>高校选课系统首页</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .STYLE1 {color: #FF0000} .STYLE3 {color: #FF0000; font-size: 9pt; } .STYLE7 {font-size: 9pt} --> </style></head>
资源推荐
资源详情
资源评论
收起资源包目录
高校选课系统 源码 strcts2 spring (142个子文件)
CourseDao.class 5KB
StuUserAction.class 5KB
StuUserDao.class 4KB
CourseAction.class 3KB
SpecialtyDao.class 3KB
Course.class 3KB
UserLoginDao.class 3KB
StuUser.class 2KB
StatInfoAction.class 2KB
SpecialtyAction.class 2KB
CharacterEncodingFilter.class 2KB
Specialty.class 2KB
UserLogin.class 2KB
UserLoginAction.class 2KB
RegAction.class 1KB
UpdatePwdAction.class 1KB
ICourseDao.class 1KB
StuCourse.class 1KB
IStuUserDao.class 747B
ISpecialtyDao.class 722B
IUserLoginDao.class 485B
.classpath 3KB
org.eclipse.wst.common.component 483B
org.eclipse.wst.jsdt.ui.superType.container 49B
css.css 1KB
style.css 944B
Thumbs.db 22KB
topM.gif 81KB
topU.gif 57KB
bottomM.gif 18KB
mainU.gif 18KB
bottomU.gif 17KB
liftU.gif 12KB
addSpecialty.gif 8KB
addCourse.gif 4KB
spring.jar 2.81MB
hibernate3.jar 2.64MB
poi-3.2-FINAL-20081019.jar 1.36MB
iText-2.1.3.jar 1.02MB
mysql-connector-java-5.1.6-bin.jar 687KB
commons-collections.jar 558KB
struts.jar 537KB
javassist-3.4.GA.jar 460KB
antlr-2.7.6.jar 433KB
spring-webmvc.jar 393KB
standard.jar 384KB
log4j-1.2.15.jar 383KB
iTextAsian.jar 322KB
dom4j-1.6.1.jar 307KB
hibernate-annotations.jar 273KB
jaxen-1.1-beta-7.jar 222KB
commons-beanutils.jar 184KB
commons-digester.jar 164KB
commons-dbcp.jar 119KB
hibernate-entitymanager.jar 116KB
hibernate-commons-annotations.jar 65KB
commons-pool.jar 61KB
commons-logging.jar 59KB
spring-webmvc-struts.jar 36KB
jstl.jar 20KB
slf4j-api-1.5.0.jar 16KB
jta.jar 13KB
slf4j-log4j12-1.5.0.jar 9KB
StatInfoAction.java 11KB
StuUserAction.java 5KB
CourseAction.java 4KB
CourseDao.java 4KB
StuUserDao.java 3KB
UserLoginDao.java 3KB
UserLoginAction.java 3KB
Course.java 2KB
StuUser.java 2KB
RegAction.java 2KB
SpecialtyDao.java 2KB
SpecialtyAction.java 2KB
UpdatePwdAction.java 2KB
Specialty.java 1KB
UserLogin.java 1KB
CharacterEncodingFilter.java 1KB
StuCourse.java 831B
ICourseDao.java 659B
IStuUserDao.java 513B
IUserLoginDao.java 507B
ISpecialtyDao.java 475B
topNo.jpg 118KB
index.jpg 67KB
jiantou.jpg 19KB
.jsdtscope 406B
welcome.jsp 4KB
addStuInfo.jsp 4KB
showStat.jsp 4KB
addCourse.jsp 3KB
reg.jsp 3KB
showCourse.jsp 3KB
courseInfo.jsp 3KB
stuUpdatePwd.jsp 3KB
courseInfo.jsp 3KB
addSpecialty.jsp 3KB
select.jsp 3KB
updatePwd.jsp 2KB
共 142 条
- 1
- 2
资源评论
dblackde
- 粉丝: 46
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功