Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring MVC Servlet Mapping Causing URLs to be called twice
    text
    copied!<p>I have the following web.xml:</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt; &lt;display-name&gt;cheapig&lt;/display-name&gt; &lt;!--Definição do Contexto Global do Container do Spring com recursos (beans) que são compartilhados com TODOS os Servlets e Filtros --&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- Cria o container do Spring compartilhado com todos os Servlets e Filtros --&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;listener&gt; &lt;display-name&gt;sessionListener&lt;/display-name&gt; &lt;listener-class&gt;br.com.cheapig.util.SessionListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- Filtro para controlar acesso --&gt; &lt;filter&gt; &lt;filter-name&gt;cheapigFilter&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;cheapigFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;!-- Definição do Servlet que processa todos os requests da aplicação. Como se está utilizando o Framework Spring, o servlet é o DispatcherServlet. --&gt; &lt;servlet&gt; &lt;servlet-name&gt;cheapig&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/spring/cheapig/servlet-context.xml&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;!-- Mapeamento dos Servlets e URLs --&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;cheapig&lt;/servlet-name&gt; &lt;url-pattern&gt;/cheapig/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;error-page&gt; &lt;error-code&gt;404&lt;/error-code&gt; &lt;location&gt;/WEB-INF/view/util/layout_404.jsp&lt;/location&gt; &lt;/error-page&gt; &lt;error-page&gt; &lt;error-code&gt;405&lt;/error-code&gt; &lt;location&gt;/WEB-INF/view/util/layout_405.jsp&lt;/location&gt; &lt;/error-page&gt; &lt;error-page&gt; &lt;error-code&gt;500&lt;/error-code&gt; &lt;location&gt;/WEB-INF/view/util/layout_500.jsp&lt;/location&gt; &lt;/error-page&gt; &lt;session-config&gt; &lt;session-timeout&gt;30&lt;/session-timeout&gt; &lt;/session-config&gt; </code></pre> <p></p> <p>However, when I try calling for example: "http://localhost:9191/cheapig/urlMappedToAControllerMethod/" the "urlMappedToAControllerMethod" is called twice. I guess that the problem is the mapping, because, the cheapigFilter also gets called twice before forwarding to the "urlMappedToAControllerMethod".</p> <p>What's wrong? And how could i fix it?</p> <p>Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload