初学jsp感觉有点乱,何况现在的jsp已经没落了,学它只是帮助我去了解它,如果碰到它该如何入手
jsp的本质还是servlet,所以用于交互的关键代码就是从servlet端发送(代码的示例是关于分页的部分代码)
List<Student> list=new StudentDAO().splitPageStu(currentS, currentP);
request.setAttribute("list", list);
request.setAttribute("currentPage", currentPage);
request.setAttribute("currentSize", currentSize);
request.getRequestDispatcher("show.jsp").forward(request, response);
在jsp中接收
<%
List<Student> list = (List<Student>)request.getAttribute("list");
String currentSize = (String)request.getAttribute("currentSize");
String currentPage = (String)request.getAttribute("currentPage");
%>
强制转换拿来就能用,这也是MVC设计模式的重要核心
在jsp中有关于前端的一些代码:
background-image: url('timg (4).jpg');
background-repeat:no-repeat;
background-size:cover;
background-attachment:fixed;
这些代码是确定背景图片不会被浏览器的大小所改变