【问题标题】:GetRequestDispatcher.forward is sending me through doGet againGetRequestDispatcher.forward 再次通过 doGet 向我发送
【发布时间】:2015-04-13 03:48:43
【问题描述】:

我有一个 doGet 覆盖的 servlet。相关的部分是:

// called from doGet(req,res)
private void serviceInternal(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    log.info("servicing a request");

    // magically compute jsp path from request params (includes the
    // logging of the app/mod/act as mentioned below

   log.info(jspPath);
   request.getRequestDispatcher(jspPath).forward(request, response);
}

现在我正在记录进入服务方法的 url,如果 url 是 server:8080/context/app/mod/act?param=1,则日志消息会显示 app='app' mod='mod' act='act',我已经验证它运行良好。

当我尝试点击应该将我路由到 jsp 的东西时,出于某种愚蠢的原因,它会将我送回我的 doGet 方法!我的日志如下所示:

INFO  2015-04-12 21:35:07,511 servicing a request
INFO  2015-04-12 21:35:07,519 app='' mod='' act='' uid='null' 
INFO  2015-04-12 21:35:07,571 /WEB-INF/index.jsp
INFO  2015-04-12 21:35:07,571 servicing a request
INFO  2015-04-12 21:35:07,571 app='WEB-INF' mod='index.jsp' act='' uid='null' 

但我不想通过我的doGet 发送我的 jsp - 我想将它发送到 JSP!为什么会这样做?

我的 servlet 正在捕获 "/*",如果这有帮助的话。但我没想到它会捕获 jsps。

我在这里做错了什么?

【问题讨论】:

    标签: java jsp servlets requestdispatcher


    【解决方案1】:

    我的 servlet 正在捕获“/*”,如果这有帮助的话。但我不会 预计它会捕获 jsps。

    你自己发现了问题。这就是原因。

    【讨论】:

    • 那么...我该如何让它捕获非jsp?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    • 2011-12-23
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多