private void exportScore(HttpServletRequest request, HttpServletResponse response) {
int studentId = request.getParameter(“studentid”) == null ? 0 : Integer.parseInt(request.getParameter(“studentid”).toString());
int courseId = request.getParameter(“courseid”) == null ? 0 : Integer.parseInt(request.getParameter(“courseid”).toString());
//获取当前登录用户类型
int userType = Integer.parseInt(request.getSession().getAttribute(“userType”).toString());
if(userType == 2){
//如果是学生,只能查看自己的信息
Student currentUser = (Student)request.getSession().getAttribute(“user”);
studentId = currentUser.getId();
}
Score score = new Score();
score.setStudentId(studentId);
score.setCourseId(courseId);
try {
//响应头必须设置,固定写法
response.setHeader(“Content-Disposition”, “attachment;filename=”+URLEncoder.encode(“score_list_sid_”+studentId
java项目中把数据导出到excel文件中
最新推荐文章于 2024-04-17 14:52:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)