[英]How to get the previous request form that returns an object to a Servlet?
從上面問題的最高審查答案中,Form preprocessing Servlet 和 Form postprocessing Servlet 是什么意思? 我把它放在我的 servlet 的什么地方? 我把它放在同樣的方法上嗎? 我是先調用預處理 Servlet 然后繼續提交我的 JSP 文件的表單,然后再繼續處理后處理文件嗎?
您按照下面提到的順序在同一個 servlet 中編寫這兩個代碼:
A.從請求中獲取請求參數(可能有HTML表單元素的值和顯式請求參數),如Form后處理部分所述
String myObjectId = request.getParameter("myObjectId");
Object myObject = request.getSession().getAttribute(myObjectId);
request.getSession().removeAttribute(myObjectId);
// ...
B. 執行一些業務邏輯並將請求轉發到一些JSP,如Form預處理部分所述
String myObjectId = UUID.randomUUID().toString();
request.getSession().setAttribute(myObjectId, myObject);
request.setAttribute("myObjectId", myObjectId);
request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.