Perché le pagine di rinfrescano Tomcat sono in modo permanente
-
14-11-2019 - |
Domanda
Sto sviluppando un'applicazione MVC Spring su Tomcat.Il problema è che Tomcat è pagine rinfrescanti ogni 2/3 minuti, non riesco a capire perché! La mia configurazione è
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
.
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd " ID="wibapp_id" versione="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>
.
Grazie in anticipo
Soluzione
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.
Altri suggerimenti
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.