Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring triple load controller on server start
    primarykey
    data
    text
    <p>I am using Tomcat 7 with Spring MVC 3.2.x RELEASE. The spring template code is generated by Intellij, I just added an syserr message output.</p> <p>When I start the server the default controller is called three times, and only on start up, after that it works fine. Is there a configuration error on my part or is it a bug?</p> <p>Here is the configuration files:</p> <pre class="lang-java prettyprint-override"><code>@Controller @RequestMapping("/") public class HelloController { private static int t = 0; @RequestMapping(method = RequestMethod.GET) public String printWelcome(ModelMap model) { model.addAttribute("message", "Hello world!"); System.err.println("Print num: " + (++t)); return "hello"; } } </code></pre> <p>//Output</p> <pre><code>INFO: Root mapping to handler 'helloController' Jun 22, 2013 1:41:21 AM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet 'mvc-dispatcher': initialization completed in 413 ms [2013-06-22 01:41:21,561] Artifact SpringTest:war exploded: Artifact is deployed successfully Print num: 1 Print num: 2 Print num: 3 Jun 22, 2013 1:41:22 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/favicon.ico] in DispatcherServlet with name 'mvc-dispatcher' Jun 22, 2013 1:41:30 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Users\Milky\apache-tomcat-7.0.41\webapps\manager </code></pre> <pre class="lang-xml prettyprint-override"><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt; &lt;context:component-scan base-package="com.springapp.mvc"/&gt; &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix" value="/WEB-INF/pages/"/&gt; &lt;property name="suffix" value=".jsp"/&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <pre class="lang-xml prettyprint-override"><code>&lt;web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt; &lt;display-name&gt;Spring MVC Application&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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