Results 1 to 2 of 2

Thread: how can spring mvc mapping to /*

  1. #1
    Join Date
    Jul 2007
    Posts
    18

    Default how can spring mvc mapping to /*

    I'm curious how can springMVC mapping to /*

    I tried my example, one servlet which mapping to "/*" just render one jsp page "/WEB-INF/jsps/hello.jsp"

    Code:
    	
    <servlet>
    	<servlet-name>helloServlet</servlet-name>
    	<servlet-class>my.HelloServlet</servlet-class>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
    	<servlet-name>helloServlet</servlet-name>
    	<url-pattern>/*</url-pattern>
    </servlet-mapping>
    and the java code is:

    Code:
    public class HelloServlet extends HttpServlet {
        public void doGet(HttpServletRequest request, HttpServletResponse response){
            request.getRequestDispatcher("/WEB-INF/jsps/hello.jsp").forward(request, response);
        }
    }
    but this will failed with infinite loop

    Since the helloServlet mapping to /*, it will also catch the requestDispatcher's forward and cause the infinitely loop.

    How do springMVC resolve this issue?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    It will only pass through the servlet again if the file cannot be found/rendered... Also if you are loading images etc in your jsp those will also hit the servlet...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •