2016-01-16 45 views
2

我有以下代码:如何在RequestDispatcher.forward之后避免在浏览器地址栏中显示参数?

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

它显示在浏览器地址栏中,除了参数的成功forwording。事情是这样的:

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

我不想表现出任何的参数(例如用户名密码)在浏览器地址栏中forwording后。 我该怎么办?

+0

你能解决这个问题吗? – Perdomoff

+0

我犯了一个小错误。我在jsp中使用了一个GET方法。 – Albert

回答

3

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

+0

我的课程扩展了HttpServlet。我在doPost(HttpServletRequest请求,HttpServletResponse响应)方法中做了一些说明。在doGet()方法中,我只是调用doPost()。 – Albert

+0

非常感谢你。我在jsp页面中使用了GET方法。 – Albert

相关问题