java - Spring boot not returning the error page -
html:
<section class="col-md-12 col-lg-12 datesection"> <form action="html/pmdreview.html" method="get"> <input title="choose date" class="datepicker-here" data-position="left top" name="date" id="date" required/> <input title="review full org" type="checkbox" name="reviewfullorg" id="reviewfullorg"/> <input type="submit" value="fetch data"> </form> </section>
error controller :
@controller public class apperrorcontroller implements errorcontroller{ /** * error attributes in application */ private errorattributes errorattributes; private final static string error_path = "/error"; /** * controller error controller * @param errorattributes */ public apperrorcontroller(errorattributes errorattributes) { this.errorattributes = errorattributes; } /** * supports html error view * @param request * @return */ @requestmapping(value = error_path, produces = "text/html") public modelandview errorhtml(httpservletrequest request) { return new modelandview("/errors/error", geterrorattributes(request, false)); } /** * supports other formats json, xml * @param request * @return */ @requestmapping(value = error_path) @responsebody public responseentity<map<string, object>> error(httpservletrequest request) { map<string, object> body = geterrorattributes(request, gettraceparameter(request)); httpstatus status = getstatus(request); return new responseentity<map<string, object>>(body, status); } /** * returns path of error page. * * @return error path */ @override public string geterrorpath() { return error_path; } private boolean gettraceparameter(httpservletrequest request) { string parameter = request.getparameter("trace"); if (parameter == null) { return false; } return !"false".equals(parameter.tolowercase()); } private map<string, object> geterrorattributes(httpservletrequest request, boolean includestacktrace) { requestattributes requestattributes = new servletrequestattributes(request); return this.errorattributes.geterrorattributes(requestattributes, includestacktrace); } private httpstatus getstatus(httpservletrequest request) { integer statuscode = (integer) request .getattribute("javax.servlet.error.status_code"); if (statuscode != null) { try { return httpstatus.valueof(statuscode); } catch (exception ex) { } } return httpstatus.internal_server_error; } }
i not able display error page mentioned in apperrorcontroller. if code throws error, debugger hits public responseentity<map<string, object>> error(httpservletrequest request) {
code redirects me pmdreview.html
page. empty 1 without data.
the line new responseentity<map<string, object>>(body, status);
in apperrorcontroller has error information.
i need redirect error page. missing something?
Comments
Post a Comment