【问题标题】:How to avoid show parameters in the browser address bar after RequestDispatcher.forward?RequestDispatcher.forward后如何避免在浏览器地址栏中显示参数?
【发布时间】:2016-01-16 13:36:05
【问题描述】:

我有以下代码:

RequestDispatcher dispatcher = request.getRequestDispatcher(viewName);
// while viewName is another servlet name;
dispatcher.forward(request, response);

除了参数显示在浏览器地址栏外,这是一个成功的转发。像这样的:

http://localhost:8080/testweb/action/LoginAction/login?username=apcpros%40163.com&password=12234

我不想在转发后在浏览器地址栏中显示任何参数(例如 usernamepassword)。 我该怎么办?

【问题讨论】:

  • 你能解决这个问题吗?
  • 我犯了一个小错误。我在jsp中使用了GET方法。

标签: java forward requestdispatcher


【解决方案1】:

作为 POST 而不是 GET 转发?这是一个 GET,如果它包含参数,则需要转发或删除它们。

【讨论】:

  • 我的类扩展了 HttpServlet。我在 doPost(HttpServletRequest request, HttpServletResponse response) 方法中做了前言。在 doGet() 方法中,我只是调用 doPost()。
  • 非常感谢。我在jsp页面中使用了GET方法。
猜你喜欢
  • 2013-02-26
  • 1970-01-01
  • 2012-08-15
  • 1970-01-01
  • 1970-01-01
  • 2013-07-12
  • 1970-01-01
  • 2023-03-18
  • 1970-01-01
相关资源
最近更新 更多