xiaodududu / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Use getRequestDispatcher forward cause page not found #549

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In web.xml, I set
    <servlet>
        <servlet-name>s</servlet-name>
        <servlet-class>guice.SimpleServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>s</servlet-name>
        <url-pattern>/bug</url-pattern>
    </servlet-mapping>

in this servlet, it has only one line, forward to next page
request.getRequestDispatcher("/forward.zul").forward(request, response);

When I link to 
http://localhost:9080/zkdemo/bug
It can fprward to forward.zul page

But when I use guice to config, it won't work
    <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <display-name>Guice initialization</display-name>
        <listener-class>guice.GuiceContextListener</listener-class>
    </listener>

Original issue reported on code.google.com by qk168...@gmail.com on 6 Oct 2010 at 8:16

Attachments:

GoogleCodeExporter commented 9 years ago
Looks like a bug in com.google.inject.servlet.ServletDefinition#doService near 
line 206:
          pathInfo = getRequestURI().substring(getContextPath().length()).replaceAll("[/]{2,}", "/")
              .substring(servletPathLength);

In my application, a request for 
/run/test@example.com/examples.ListIterationBenchmark bottoms out in a JSP, 
with this request dispatcher:
    request.getRequestDispatcher("/BenchmarkPage.jsp").forward(request, response);
This fails horribly with an error trying to dispatch to a guice-servlet mangled 
URL:
    /runchmarkPage.jsp

Original comment by limpbizkit on 20 Oct 2010 at 11:16

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 23 Oct 2010 at 11:45