我正在开发在Tomcat上的Spring MVC应用程序。问题是Tomcat正在刷新页面每2/3分钟,我看不到为什么! 我的配置是

web.xml

<?xml version="1.0" encoding="UTF-8"?>
.

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd“ id=“webapp_id”版本=“2.5”>

<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>messages</param-value>
</context-param>
<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
    <param-value>fr</param-value>
</context-param>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:portal.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>portal</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            <!--
                desactivation du context : utilisation du context parent
            -->
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>portal</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>portal</servlet-name>
    <url-pattern>/index.htm</url-pattern>
</servlet-mapping>  
<servlet-mapping>
    <servlet-name>portal</servlet-name>
    <url-pattern>*.ajax</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<session-config>
    <session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>index.htm</welcome-file>
</welcome-file-list>
<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>false</el-ignored>
        <page-encoding>UTF-8</page-encoding>
        <scripting-invalid>false</scripting-invalid>
    </jsp-property-group>
</jsp-config>
.

server.xml

      <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
           prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
    -->
    <!--
   <Context docBase="/home/badrux/Work/apache-tomcat-6.0.26/webapps/portal" path="/" reloadable="true"></Context>
    -->
   <Context path="/images" docBase="/root/collecte/images" reloadable="false"/>
   <Context path="/statics" docBase="/root/collecte/statics" reloadable="false"/>
   <Context path="/sitemap" docBase="/root/collecte/sitemap" reloadable="false"/>
  </Host>
.

提前感谢

有帮助吗?

解决方案

Server cannot refresh page by itself, there is no simple way of achieving that. If you really experiencing such behavior, then somewhere in your code you have an explicit refresh (redirect perhaps? JavaScript maybe?) or AJAX is forcing page reload.

Please note that I said "simple way". You could do that by more sophisticated technologies, but it is highly unlikely that you are doing that.

其他提示

You have a:

<meta http-equiv="refresh" content="240" />

in the page header, which means you are telling the browser to refresh the page every 4 minutes (240 seconds).

As an additional observation, you're also creating a session when rendering the home page, which is probably an unnecessary overhead.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top