2016-01-16 42 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

相關問題