jsp客户端去缓存和服务端去缓存
网页缓存的作用是什么?应该很重要。但是我们在开发网络应用的时候,网页缓存总是给我们一种莫名的烦恼。于是几乎每一个开发者都试图解决过这个问题。当然,我也不是今天才着手解决这个问题。但是今天一时心血来潮,写一篇,记录一下用到的方法。
1.禁止客户端缓存要在<head>中加入类似如下内容(我当然还没有这么用过):
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
2.在服务器的动态网页中禁止缓存,要加入类似如下脚本
(1)asp(好久不用了):
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
%>
(2)jsp(我现在经常用的):
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
相关文档:
JSP基本语法与定义
先来看一段简单的小程序:
程序:
1.jsp
<html>
<head>
<title>example</title>
</head>
1
<%@ page language=”java” %>
2
<%@ page
contentType=”text/html,charset=”GB2312””>
3
......
对于HTM网页,加入:
<meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<meta HTTP-EQUIV="expires" CONTENT="0">
然后,jsp页面中加入:
<%
response.setHeader("Cache-Control","no-store") ......
<%@ page language="java" import="kg.TestBean2;" %>
<%@ page contentType="text/html;charset=gb2312" %>
<html>
<head>
<title>HelloBean</title>
</head>
<body>
<%--
<%
kg.TestBean2 testbean=(kg.TestBean2)session.setAttribute("testbean");
if ......
<%@ page language="java" import="kg.TestBean2;" %>
<%@ page contentType="text/html;charset=gb2312" %>
<html>
<head>
<title>HelloBean</title>
</head>
<body>
<%--
<%
kg.TestBean2 testbean=(kg.TestBean2)session.setAttribute("testbean");
if ......
树节点组合模型
package cn.com.jsnh.model.catalog;
public class TreeModel {
private String node;
private CatalogModel model;
public String getNode() {
return node;
}
public void setNode(String node) {
this.node = node;
}
public CatalogModel getModel() {
return model;
}
public void setMo ......