session变量的操作

类别:Java 点击:0 评论:0 推荐:

将变量放入session中去 例:session.putValue("anchor",v_key);

<%@ page contentType="text/html;charset=gb2312" %> <%@ page info="database handler"%> <%@ page import="java.io.*"%> <%@ page import="java.util.*"%> <%@ page import="java.sql.*"%> <% request.setCharacterEncoding("gb2312"); String v_file_name = request.getParameter("filename"); String v_key = request.getParameter("key"); //将变量v_file_name,v_key放入session中去 session.putValue("bodyFile",v_file_name); session.putValue("anchor",v_key); if(v_file_name!=null && v_key!=null) { response.sendRedirect(request.getContextPath() +"/jsp/help.jsp#"+v_key); } %>

取出session变量 例:session.getValue("anchor");

<%@ page language="java" %> <%@ taglib uri="/WEB-INF/tld/struts-tiles.tld" prefix="tiles" %> <%@ page contentType="text/html;charset=gb2312" %> <% /* get param from session */ session.getValue("bodyFile"); session.getValue("anchor"); %> <tiles:insert template="./helpFramesetLayout.jsp"> <tiles:put name="title" content="*TGPMS使用帮助*" /> <tiles:put name="header" content="<%="/jsp/search.jsp"%>" direct="true" /> <tiles:put name="body" content="<%="/jsp/manual/"+session.getValue("bodyFile")+"#"+session.getValue("anchor")%>" direct="true" /> <tiles:put name="footer" content="<%="/jsp/footer.html"%>" direct="true" /> </tiles:insert>

本文地址:http://com.8s8s.com/it/it15314.htm