0
我在寫一個servlet過濾器。我想添加錯誤並將響應發回到請求來自的頁面。添加錯誤並將請求發送回請求頁面servlet過濾器
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
final HttpServletRequest servletRequest = (HttpServletRequest)request;
final HttpServletResponse servletResponse = (HttpServletResponse) response;
//add error and redirect the request to previous page
chain.doFilter(request, response);
}
我知道,我們可以重定向響應,
servletResponse.sendRedirect("/WebContent/Error.jsp");
請讓我知道如何添加錯誤信息併發送請求回。
我想添加一些自定義錯誤消息。 "Validation failed. Please try again".
由於提前