各位我是一名JSP新手,我这段时间用JSP写了个简单的论坛,但在插入数据和删除数据时,页面一直保留原先状态,只有当点击刷新时才能显示结果,请问各问"大虾"是怎么会事???

解决方案 »

  1.   

    工具/internet选项/设置/每次访问此页检查
      

  2.   

    对这为仁兄hmsxq(hm)答复:
      那种功能我使用了,可是依然还是不行!
      

  3.   

    不使用页面缓存就可以了
               response.setHeader("Cache-Control", "no-cache");
               response.setHeader("Pragma", "no-cache");
      

  4.   

    加入js,在插入数据时就调用一个函数,refresh一下,
      

  5.   

    那肯定的。读了cache里的数据。你用上面哪个函数看看。。
      

  6.   

    在 META里设置一下属性啊  有刷新时间和自动刷新的
      

  7.   

    在插入数据和删除数据后,jsf有个action函数,插入数据和删除数据成功后将返回一个字符串,然后再到faces-config.xml中成功后转向的叶面 ,这样出来的结果肯定是新的结果,明白,我想STRUTS,一样的把,当然你也可以在叶面,直接通过javascript转向本叶面,方法绝对有效,因为这问题,作WEB开发的都会遇到的,你可以尝试一下
      

  8.   

    比如,我这是一个window.open()叶面,要提交数据后刷新父叶面,我就通过这方法完成的,比你的问题复杂点,代码如下,
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page isErrorPage="true" language="java" contentType="text/html; charset=SHIFT_JIS" pageEncoding="SHIFT_JIS"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <html>
    <head>
    <link href="../css/edit.css" type="text/css" rel="stylesheet">
    <title>出退勤データ編集.........................................................................</title>
    <style type="text/css">
    <!--  
    body {
      margin-top: 5px;
    margin-left: 5px;
    margin-right: 5px;
    margin-bottom: 5px;
    background-color: #ECE9D8;
    }
    -->
    </style>
    <script language="JavaScript" type="text/JavaScript">
      function closeWin()
    {
        window.close();
        window.opener.location.href='/attendance/jsp/main.jsf?thismonth=<c:out value="${SelectInfo.currentMonth}"/>&thisyear=<c:out value="${SelectInfo.currentYear}"/>&userID=<c:out value="${SelectInfo.openUserID}"/>&name=<c:out value="${SelectInfo.openUserName}"/>';
    }
    </script> 
    </head>
    <body>
    <f:view>
    <h:form id="mainForm">
    <table width="100%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
      <tr bgcolor="#ECE9D8">
        <td width="30%"> 出社時刻</td>
        <td>
          <h:inputText id="startTime" styleClass="input_large" value="#{EditDateForm.startTime}"/>
        </td>
      </tr>
      <tr bgcolor="#ECE9D8">
        <td> 退社時刻</td>
        <td>
         <h:inputText id="endTime" styleClass="input_large" value="#{EditDateForm.endTime}"/>
        </td>  
      </tr>
      <tr bgcolor="#ECE9D8">
        <td> 休暇種類</td>
        <td>
        <h:selectOneMenu value="#{EditDateForm.holidayType}" id="holidayType" styleClass="select_large">
    <f:selectItems value="#{EditDateForm.holidayList}"/>                         
    </h:selectOneMenu>
        </td>
      </tr>
      <tr bgcolor="#ECE9D8">
        <td> 備考</td>
        <td>
         <h:inputTextarea id="content" cols="25" rows="5" value="#{EditDateForm.content}"/>
        </td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td colspan="2" align="center" bgcolor="#ECE9D8">
      <h:commandButton id="login" action="#{EditDateCtrl.editDateButton}" onclick="closeWin();" value="登 録"/>
      <h:commandButton id="Submit" onclick="window.close();" value="閉じる"/>
        </td>
        </tr>
    </table>
    </h:form>
    </f:view>
    </body>
    </html>
    这里是调用,
    <h:commandButton id="login" action="#{EditDateCtrl.editDateButton}" onclick="closeWin();" value="登 録"/>
    这里你关心的代码:
    <script language="JavaScript" type="text/JavaScript">
      function closeWin()
    {
        window.close();
        window.opener.location.href='/attendance/jsp/main.jsf?thismonth=<c:out value="${SelectInfo.currentMonth}"/>&thisyear=<c:out value="${SelectInfo.currentYear}"/>&userID=<c:out value="${SelectInfo.openUserID}"/>&name=<c:out value="${SelectInfo.openUserName}"/>';
    }
    </script> 
    当然如果你不用 javascript的话,可以直接在后台控制,在这里的方法中写
    action="#{EditDateCtrl.editDateButton}"