如何用session记录游客所浏览的内容
发布网友
发布时间:2022-05-20 10:27
我来回答
共2个回答
热心网友
时间:2023-10-16 07:29
一个简单的例子,JSP的.原理就这样,其他自己变.
session.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>session.html</title>
</head>
<pre>
<body>
<h2>书的名字是:</h2>
<form action="session1.jsp" method=get>
<input type = text name = "sm">
<input type =submit value="确定"> <input type = reset value="重来">
</form>
</body>
</pre>
</html>
===========================
session1.jsp
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%request.setCharacterEncoding("gb2312"); %>
<%
session.putValue("sm",sm);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>session1 a test of session</title>
</head>
<pre>
<h2>
<body>
书名是:<%=sm %>
<form action = "session2.jsp" method = post >
作者是:
<input type = text name = "zuozhe"> <input type = hidden name="sm" value=<%=sm %>>
<input type = submit value="确定"> <input type = reset value="取消">
</body>
</h2>
</pre>
</html>
====================
session2.jsp
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%request.setCharacterEncoding("gb2312"); %>
<%
sm = (String)session.getValue("sm");
String zuozhe = request.getParameter("zuozhe");
%>
<html>
<head>
<title>session2 a test of session</title>
</head>
<pre>
<body>
<h2>
书名是:<%=sm %>
作者是:<%=zuozhe %>
</h2>
</body>
</pre>
</html>
热心网友
时间:2023-10-16 07:29
用日志功能
每进一个actoin插入该action跳转的页面
再读取出他的 操作日志
就可以里