package com.xxxx.controller;
import com.xxxx.entity.LotteryRecord;
import com.xxxx.service.LotteryRecordService;
import com.xxxx.mapper.LotteryMapperImpl;
import com.xxxx.mapper.LotteryRecordMapper;
import com.xxxx.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSessionFactory;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/center")
public class LotteryRecordServlet extends HttpServlet {
public static int userId;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// 获取 SqlSessionFactory 实例
SqlSessionFactory sqlSessionFactory = MyBatisUtil.getSqlSessionFactory();
int userId = Integer.parseInt(req.getParameter("userId"));
// 创建 LotteryRecordMapperImpl 实例
LotteryRecordMapper mapper = new LotteryMapperImpl(sqlSessionFactory);
// 创建 LotteryRecordService 实例
LotteryRecordService service = new LotteryRecordService(mapper);
// 获取中奖记录
List<LotteryRecord> records = service.getLotteryRecordsByUserId(userId);
// 将记录添加到请求属性
req.setAttribute("lotteryRecords", records);
// 转发到 JSP 页面
RequestDispatcher dispatcher = req.getRequestDispatcher("/center.jsp");
dispatcher.forward(req, resp);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
loginProject.zip (85个子文件)
loginProject
src
mysql.properties 160B
mybatis-config.xml 885B
com
xxxx
mapper
UserMapper.java 145B
UserMapper.xml 389B
LotteryMapperImpl.java 780B
LotteryRecord.java 432B
LotteryRecordMapper.java 203B
LotteryRecordMapper.xml 731B
controller
UserServlet.java 1KB
LotteryRecordServlet.java 2KB
service
UserService.java 2KB
LotteryRecordService.java 502B
UserService2.java 276B
entity
LotteryRecord.java 1KB
User.java 1KB
vo
MessageModel.java 612B
test
Test.java 488B
util
MyBatisUtil.java 768B
GetSqlSession.java 1011B
StringUtil.java 213B
out
artifacts
loginProject_war_exploded
WEB-INF
classes
mysql.properties 160B
mybatis-config.xml 885B
META-INF
loginProject.kotlin_module 16B
com
xxxx
mapper
LotteryRecordMapper.class 271B
UserMapper.xml 389B
UserMapper.class 188B
LotteryMapperImpl.class 2KB
LotteryRecord.class 873B
LotteryRecordMapper.xml 731B
controller
UserServlet.class 2KB
LotteryRecordServlet.class 2KB
service
UserService.class 2KB
UserService2.class 587B
LotteryRecordService.class 771B
entity
User.class 2KB
LotteryRecord.class 2KB
vo
MessageModel.class 1KB
test
Test.class 1KB
util
MyBatisUtil.class 1KB
GetSqlSession.class 2KB
StringUtil.class 565B
lib
mybatis-3.5.6.jar 1.66MB
mysql-connector-j-8.4.0.jar 2.42MB
web.xml 304B
index.jsp 327B
center.jsp 811B
js
jquery-3.7.1.js 289KB
maintanance.jsp 3KB
login.jsp 1KB
production
loginProject
mysql.properties 160B
mybatis-config.xml 885B
META-INF
loginProject.kotlin_module 16B
com
xxxx
mapper
LotteryRecordMapper.class 271B
UserMapper.xml 389B
UserMapper.class 188B
LotteryMapperImpl.class 2KB
LotteryRecord.class 873B
LotteryRecordMapper.xml 731B
controller
UserServlet.class 2KB
LotteryRecordServlet.class 2KB
service
UserService.class 2KB
UserService2.class 587B
LotteryRecordService.class 771B
entity
User.class 2KB
LotteryRecord.class 2KB
vo
MessageModel.class 1KB
test
Test.class 1KB
util
MyBatisUtil.class 1KB
GetSqlSession.class 2KB
StringUtil.class 565B
web
WEB-INF
lib
mybatis-3.5.6.jar 1.66MB
mysql-connector-j-8.4.0.jar 2.42MB
web.xml 304B
index.jsp 327B
center.jsp 811B
js
jquery-3.7.1.js 289KB
maintanance.jsp 3KB
login.jsp 1KB
.idea
uiDesigner.xml 9KB
artifacts
loginProject_war_exploded.xml 523B
workspace.xml 20KB
misc.xml 282B
modules.xml 271B
.gitignore 184B
loginProject.iml 2KB
共 85 条
- 1
资源评论
zyzdnr
- 粉丝: 8
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功