package com.aaa.service;
import java.util.List;
import java.util.Map;
public interface IStudentService {
List<Map<String,Object>> listAll();
}
package com.aaa.service.impl;
import com.aaa.dao.IStudentDAO;
import com.aaa.dao.impl.StudentDAOImpl;
import com.aaa.service.IStudentService;
import java.util.List;
import java.util.Map;
/**
* @author: hy
* @create: 2022-07-26 12:06:00
*/
public class StudentServiceImpl implements IStudentService {
private IStudentDAO studentDAO=new StudentDAOImpl();
@Override
public List<Map<String, Object>> listAll() {
return null;
}
}
package com.aaa.servlet;
import com.aaa.service.IStudentService;
import com.aaa.service.impl.StudentServiceImpl;
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.io.PrintWriter;
import java.util.List;
import java.util.Map;
/**
* @author: hy
* @create: 2022-07-26 11:45:15
*/
@WebServlet(urlPatterns = "/xxx") //配置当前servlet处理的映射请求地址
public class TestServlet extends HttpServlet {
//如果一个java程序想要处理web请求,必须实现Servlet接口
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
IStudentService studentService = new StudentServiceImpl();
List<Map<String,Object>> list = studentService.listAll();
//拼接html页面
StringBuilder myhtml = new StringBuilder();
myhtml.append("<html>");
myhtml.append("<head>");
myhtml.append("<title>my page</title>");
myhtml.append("</head>");
myhtml.append("<body><h1>我的页面 aaa page</h1></body>");
myhtml.append("</html>");
//使用打印输出流对象,将html内容,输出给浏览器客户端
PrintWriter out = resp.getWriter();
out.println(myhtml);
out.flush();
out.close();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/118085.html