javax.servlet.ServletException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

This is a bug in Spring Framework, issue SPR-4518 and it's fixed in v3.0 M3. If you want to see more about the bug, check the source.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • When I add @ResponseBody on the method level as follows: {code:java} @Controller //@ResponseBody public class UserController { @RequestMapping("/hello") @ResponseBody public String hello() { return "hello"; } } {code} It works as expected. However, if I add the annotation on the type level: {code:java} @Controller @ResponseBody public class UserController { @RequestMapping("/hello") //@ResponseBody public String hello() { return "hello"; } } {code} Then an exception is thrown: Servlet.service() for servlet [dispatcher] in context with path [/practice] threw exception [Circular view path [hello]: would dispatch back to the current handler URL [/practice/main/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause javax.servlet.ServletException: Circular view path [hello]: would dispatch back to the current handler URL [/practice/main/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:205) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
    via by 俞火江,
  • When I add @ResponseBody on the method level as follows: {code:java} @Controller //@ResponseBody public class UserController { @RequestMapping("/hello") @ResponseBody public String hello() { return "hello"; } } {code} It works as expected. However, if I add the annotation on the type level: {code:java} @Controller @ResponseBody public class UserController { @RequestMapping("/hello") //@ResponseBody public String hello() { return "hello"; } } {code} Then an exception is thrown: Servlet.service() for servlet [dispatcher] in context with path [/practice] threw exception [Circular view path [hello]: would dispatch back to the current handler URL [/practice/main/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause javax.servlet.ServletException: Circular view path [hello]: would dispatch back to the current handler URL [/practice/main/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:205) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
    via by 俞火江,
  • GitHub comment 9183#131106046
    via GitHub by orubel
    ,
  • MarshallingView in Spring MVC 3
    via Stack Overflow by Alfredo Osorio
    ,
    • javax.servlet.ServletException: Circular view path [hello]: would dispatch back to the current handler URL [/practice/main/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:205) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)

    Users with the same issue

    Unknown visitor1 times, last one,
    rocday
    2 times, last one,
    derprogger
    1 times, last one,
    tomthomas
    320 times, last one,
    Luka
    8 times, last one,
    34 more bugmates