【发布时间】:2012-02-24 13:57:50
【问题描述】:
我们使用 JBoss 5.1 和 Guice 3.0,需要使用以下技术从 Guice servlet 转发到外部 Servlet:
@Inject HttpServletRequest request;
@Inject HttpServletResponse response;
@GET
@Produces("application/octet-stream")
@Path("/get/1234")
public void fwd() throws ServletException, IOException {
String newURL = "/ExternalServlet?action=1234";
RequestDispatcher dispatcher = request.getRequestDispatcher(newURL);
dispatcher.forward(request, response);
}
在我们的几个开发服务器上,这会转发到正确的 url(例如 localhost/ourApp/ExternalServlet),但在我们的生产登台服务器上,它会在 /get/1234 之前添加,因此 url 会转发到 localhost/ourApp/get /1234/外部Servlet。重定向有效。
知道为什么前锋在 Guice servlet 之前添加了吗?谢谢。
【问题讨论】:
标签: servlets request guice jboss5.x guice-servlet