Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

Spring MVC directly returns a View skipping the content inside the method

I am working in a springMVC application. I have a request mapping which is directly returning a view without processing the lines in between.

@RequestMapping(value = { "/testCnt" }, method = { RequestMethod.GET })
public ModelAndView testContent(HttpServletRequest request) {

    log.debug("testing debug);
    ModelAndView mnv = new ModelAndView();
    log.debug("testssss");
    log.debug("test purpose");
    //some procesing here....Calling other methods and doing the required process
   ........
   ........
   mnv.setViewName("returnjsp");
    return mnv;
}

So for the above code i can see the following in the log statements:

2017-11-26 22:01:56,388 DEBUG org.springframework.web.servlet.DispatcherServlet DispatcherServlet with name 'SiteServlet' processing GET request for [/mysite/site/ContentTest/testCnt]
2017-11-26 22:01:56,389 DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping Looking up handler method for path /ContentTest/testCnt
2017-11-26 22:01:56,394 DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping Returning handler method [public org.springframework.web.servlet.ModelAndView myproject.org.com.TestCountController.testContent(javax.servlet.http.HttpServletRequest)]
2017-11-26 22:01:56,394 DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory Returning cached instance of singleton bean 'testCountController'
2017-11-26 22:01:56,401 DEBUG org.springframework.web.servlet.DispatcherServlet Last-Modified value for [/portal/site/ContentTest/testCnt
] is: -1


2017-11-26 22:01:58,850 DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory Invoking afterPropertiesSet() on bean with name 'returnjsp'

I dont see my log statements in the log which is the very first line of the execution. It directly returns a view to "returnjsp" without processing the content in this method. Please help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try adding a timer or a sleep function below the log. lines.

Use java.util.concurrent.TimeUnit and then: TimeUnit.SECONDS.sleep(1);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...