<input type=submit value="返回" onClick="history.go(-1);">
解决方案 »
- swing 怎么才能即时重画
- 关于贪吃蛇的程序的一些问题(关于算法方面的)
- 关于异常的处理谁帮个忙啊
- 大问题请教
- 怎么用一个方法得到所有类的实例
- try语句里面能否再放一个try语句?
- Swing中跨平台地加载图片的语句是...?
- 各位高手请帮忙!哪里可以下载mysql的驱动程序!怎样配制classpath!
- 如何对ResultSet进行过滤呢?好像没有相应的方法似的?
- 求大神使用ImageIO输出/入位图 table=ImageIO.read(new File("image/board.jap");括号里是绝对还相对路径
- 怎样用JAVA生成DLL动态库或控键吗?
- 奇闻:Apache+Apache JServ 1.1.1+1G内存居然报内存不够,那位高友知道参数设置,把俺的1G内存都利用起来,感激不尽啊
用 forward 关键字行不行
这样很快的啊,
back里面不要用参数
String request_url=request.getHeader("Referer");
response.sendRedirect(request_url);
return;
你确认在IE里点“返回”就比这样快?
String request_url=request.getHeader("Referer");
out.print("<a href="+request_url+">返回</a>");
你重新显示A的时候需要从资源(例如数据库)中读取吗?如果是,有一个办法是放大数据放到session中,当然要大大牺牲服务器资源了,看你权衡的结果。
package mine;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Example using servlet initialization and the
* getLastModified method.
*/
public class LotteryNumbers extends HttpServlet {
private long modTime;
private int[] numbers = new int[10];
/** The init method is called only when the servlet
* is first loaded, before the first request
* is processed.
*/
public void init() throws ServletException {
// Round to nearest second (ie 1000 milliseconds)
modTime = System.currentTimeMillis()/1000*1000;
for(int i=0; i<numbers.length; i++) {
numbers[i] = randomNum();
}
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Your Lottery Numbers";
out.println(ServletUtilities.headWithTitle(title) +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<B>Based upon extensive research of " +
"astro-illogical trends, psychic farces, " +
"and detailed statistical claptrap, " +
"we have chosen the " + numbers.length +
" best lottery numbers for you.</B>" +
"<OL>");
for(int i=0; i<numbers.length; i++) {
out.println(" <LI>" + numbers[i]);
}
out.println("</OL>" +
"</BODY></HTML>");
}
/** The standard service method compares this date
* against any date specified in the If-Modified-Since
* request header. If the getLastModified date is
* later, or if there is no If-Modified-Since header,
* the doGet method is called normally. But if the
* getLastModified date is the same or earlier,
* the service method sends back a 304 (Not Modified)
* response, and does <B>not</B> call doGet.
* The browser should use its cached version of
* the page in such a case.
*/
public long getLastModified(HttpServletRequest request) {
return(modTime);
}
// A random int from 0 to 99.
private int randomNum() {
return((int)(Math.random() * 100));
}
}
主要的函数在于:
public long getLastModified(HttpServletRequest request) {
return(modTime);
}
只是后退也会看到随机数并没有更改。