如果只從特定的servlet重定向,我想對JSP執行操作,否則什麼也不做。是否有可能?如果從servlet重定向,請對JSP執行操作
在我的JSP中定義了不同的錯誤。這個JSP調用一個servlet(contentType爲application/pdf),它在新標籤頁中打開並搜索25秒的PDF,然後如果未找到PDF,則重定向到顯示錯誤消息「找不到文件」的相同JSP。我想顯示錯誤,如果從servlet調用,否則什麼也不做。
JSP代碼:
<%}else if(hPP!=null && hPP.get("errorcode")!=null && hPP.get("errorcode").toString().equalsIgnoreCase("Issue")){%>
<c:if test="${cameFromServlet}">
<div class="SplInputField">
<label class="FontBlod">Download fail</label>
</div>
</c:if>
servlet代碼
if (content == null) {
request.setAttribute("cameFromServlet", true);
String redirectJspUrl = request.getParameter("homeRedirect");
String strReceiptPage =
redirectJspUrl.substring(0, redirectJspUrl.lastIndexOf("/")) +
"/GetQReceiptPage";
response.sendRedirect(strReceiptPage);
}
謝謝JSTL做(如果測試!= )的作品或有任何其他關鍵字不是? –
你可以使用!或者這個詞不存在也存在關鍵字 – saml
它不起作用在我的case.Sry for基本Q,但我是編程世界的新手。我已經在Q上面添加了JSP/servlet代碼 –