我正在开发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”version =“2.5”&gt;
<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>
提前致谢
答案 0 :(得分:3)
服务器无法自行刷新页面,没有简单的方法来实现。如果你真的遇到过这样的行为,那么你的代码中的某个地方你有一个显式刷新(可能是重定向?JavaScript可能?)或者AJAX正在强制页面重新加载。
请注意我说的“简单方法”。你可以通过更复杂的技术来做到这一点,但你不太可能这样做。
答案 1 :(得分:2)
你有一个:
<meta http-equiv="refresh" content="240" />
页眉中的,表示您告诉浏览器每4分钟(240秒)刷新一次页面。
作为一个额外的观察,你还在渲染主页时创建一个会话,这可能是一个不必要的开销。