今天发现一个问题,我在后台程序里修改了数据库,然后访问前台页面,为什么前台还是显示修改前的信息呢,是不是缓存问题啊,找了半天不知道哪里的问题,郁闷死了,谁帮我看看啊。

解决方案 »

  1.   

    是b/s的吗
    把ie的脱机文件清掉
    还有数据库的事务,你提交了吗
    或者直接去数据库查查,数据变更了吗
      

  2.   

      我重启Tomcat就可以了,为什么呢,一定要重启吗,可不可不重新启动
      

  3.   


    我也遇到过这样的问题,我的方法是:启动SQL server的跟踪,执行程序,然后找出跟踪到执行编译的程序的SQL语句,然后在SQL的查询窗口执行SQL语句,看看执行的SQL语句的结果是不是你修改数据库后的结果,如果是,则是最新的;如果不是,说明是以前的;这时可以考虑清空缓存看看.
      

  4.   

    必须重启,但是我们可以用代码来修改以下就OK了
    我引用专家们的方法:
    来源:baozhengw的专栏 - CSDNBlog在WEB应用中可通过ANT的API调用ant的工程配置文件来在线编译java文件,在工程配置文件中(如build.xml)将编译的class文件或者变更的xml文件直接复制到WEB-INF\classes中的对应目录,不用重新启动tomcat.由于在平台应用中经常由用户定义表结构,并由表结构生成java实体类和hibernate映射文件,通过热编译部署的方式 可不用停止WEB应用,下面是在Java中调用ant的代码,注意这种方式不是调用ant的批处理的,也不提倡这样做,下面的方式可使用户通过点击WEB页面上的按钮来调用ANT编译:package org.apache.easframework.common; import java.io.File; 
    import java.io.FileNotFoundException; 
    import java.io.FileOutputStream; 
    import java.io.PrintStream; import org.apache.tools.ant.BuildException; 
    import org.apache.tools.ant.DefaultLogger; 
    import org.apache.tools.ant.Project; 
    import org.apache.tools.ant.ProjectHelper; public class CompileJava {public static synchronized boolean compile(String buildFilePath, String logFilePath) {
    File buildFile = new File(buildFilePath); 
    Project project = new Project(); DefaultLogger consoleLogger = new DefaultLogger(); 
    try {
    FileOutputStream fs = new FileOutputStream(logFilePath); 
    PrintStream ps = new PrintStream(fs); 
    consoleLogger.setErrorPrintStream(ps); 
    consoleLogger.setOutputPrintStream(ps); 
    } catch (FileNotFoundException e1) {e1.printStackTrace(); 
    }consoleLogger.setMessageOutputLevel(Project.MSG_INFO); 
    project.addBuildListener(consoleLogger); try {
    project.fireBuildStarted(); 
    project.init(); 
    ProjectHelper helper = ProjectHelper.getProjectHelper(); 
    helper.parse(project, buildFile); 
    System.out.println("默认target:"); 
    System.out.println(project.getDefaultTarget()); //默认的target是help
    project.executeTarget("all"); //调用的task是all
    project.fireBuildFinished(null); 
    return true; } catch (BuildException e) {
    project.fireBuildFinished(e); 
    return false; 
    }}public static String startCompile(String buildFile,String logFile)
    {
    if(CompileJava.compile(buildFile, logFile))
    {
    return "编译成功!"; 
    }
    else
    {
    return "编译失败!"; 
    }
    }/**
    * @param args
    */
    public static void main(String[] args) {
    System.out.println("开始编译..."); boolean b = CompileJava.compile("D:/easdev/build/userbuild.xml",
    "D:/easdev/build/userbuild.log"); 
    if(b)
    {
    System.out.println("编译成功!"); 
    }
    else
    {
    System.out.println("编译失败!"); 
    }
    System.out.println("结束编译..."); }}
    下面是Java页面通过dwr调用此类的代码:<%@ page contentType="text/html; charset=GBK"%><%@ page import="org.apache.easframework.common.*" %>
    <%@ taglib prefix="ww" uri="webwork" %>
    <%@ include file="/common/head.jsp"%> 
    <script type='text/javascript' src='<%=request.getContextPath()%>/js/util.js?Math.random(); '></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/js/engine.js?Math.random(); '></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/CompileJava.js?Math.random(); '></script> 
    <meta http-equiv="epires" content=0>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <script language="JavaScript">
    <!-- 
    function compileJava()
    {
    CompileJava.startCompile("D:/easdev/build/userbuild.xml","D:/easdev/build/userbuild.log",callback); // document.listForm.elements['pageLoaderInfo.custSort'].value = sortValue; 
    // document.listForm.operate.value="selectPageList"; 
    // document.listForm.submit(); 
    }
    function callback(data)
    {
    alert(data); 
    }
    -->
    </script><table><tr><td><input type="button" name="compile" value="编译" class="mybutton" onClick="compileJava()"></td></tr></table>
    <%@include file="/common/tail.jsp"%> 上面在编译成功时弹出编译成功的JS提示,否则提示编译失败 另外需要说明的是,要实现在线ANT编译,需要把ant工具相关的一些jar包复制到tomcat的shared\lib或者WEB-INF\lib中.