我試圖發回一個用一些HTML編碼的HTTP。我得到「方法sendStatus(int,String)是未定義類型HttpServletResponse」錯誤。我也只用代碼嘗試過。如果我使用sendError()來代替,那麼不會發送HTML。JSP:sendStatus(int,String)方法未定義類型HttpServletResponse
<%@page contentType="text/html; charset=utf-8" %>
<%@ page isErrorPage = "true"%>
<%response.sendStatus(500, "TEST 500 ERROR WITH HTML PAGE");%>
<html>
<body>
<h1>
Test HTTP Error: 500 ERROR with HTML page
</h1>
</body>
</html>
我越來越:
ERROR_500_subjectdoc_htmlheader_error_realhtmlerrorpage.jsp:3:12: The method sendStatus(int, String) is undefined for the type HttpServletResponse
<%response.sendStatus(500, "TEST 500 ERROR WITH HTML PAGE");%>
我仍然得到的方法sendStatus(int)是未定義的類型HttpServletResponse – user994165 2012-04-27 18:45:02
@ user994165:您需要密切關注 - 我沒有說*發送*狀態,我說*設置*狀態。 – 2012-04-27 18:57:20
謝謝。這解釋瞭解析錯誤,現在它起作用了。 – user994165 2012-04-27 20:46:11