src/sanrenxing/foreMain/servlet/NoticeShowServlet.java

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package sanrenxing.foreMain.servlet;

import com.google.gson.Gson;
import sanrenxing.foreMain.dao.NoticeShowDao;
import sanrenxing.foreMain.dao.impl.NoticeShowDaoImpl;
import sanrenxing.foreMain.domain.NoticeShow;

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 javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @date 2020/10/14 22:32
 * 编辑者:邓志强
 * 功能:
 */
@WebServlet("/NoticeShowServlet")
public class NoticeShowServlet extends HttpServlet {
    //创建数据层对象
    NoticeShowDao nsd=new NoticeShowDaoImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置请求字符集
        req.setCharacterEncoding("utf-8");
        //设置响应字符集和内容类型
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html");
        //接收来自客户端方法信息
        String method=req.getParameter("method");
        if (method.equals("showNotice")){
            this.showNotice(req,resp);
        }
    }

    /**
     * 显示公告信息的方法
     * @param req
     * @param resp
     */
    private void showNotice(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        //创建输出流
        PrintWriter out=resp.getWriter();
        //通过session拿到学员编号
        HttpSession session=req.getSession();
        String stuId=(String) session.getAttribute("stuId");
        //查询出对应班级的公告信息
        List<NoticeShow> noticeShowList=nsd.findNotice(stuId);
        if (noticeShowList.size()!=0){
            //创建map集合
            Map<String,Object> map=new HashMap<>();
            map.put("data",noticeShowList);
后面还有 12 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。