在我的 JAVA 动态 Web 应用程序中,我通过 action="post" 将值从 Payment.jsp 传递到 servlet。在 servlet doPost() 方法中:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String cost=request.getParameter("COST_ID");
HttpSession session=request.getSession();
synchronized (session) {
session.setAttribute("payamount", cost);
}
request.setAttribute("cost", cost);
request.getRequestDispatcher("makepayment.jsp").forward(request, response);
}
在 makepayment.jsp 我使用 ${cost} 获得价值
我的问题是,当我进入地址栏并按 Enter 时,${cost} 什么也没有打印。
知道那是因为它调用 doGet() 方法,但我该如何解决这个问题?