java - SpringMVC using @ExceptionHandler HTTP Status 500 - Expected session attribute -


i use @exceptionhandler capture http status 500 - expected session attribute. return message same page on showing user error.

can point me example on how can handle exception , return message view instead of redirecting page.

this have far item in view not getting set error message;

@exceptionhandler(httpsessionrequiredexception.class)     public redirectview handlehttpsessionrequiredexception(exception ex, httpservletrequest request) throws exception     {         logger.info("in handlehttpsessionrequiredexception handler method");         string referrer = request.getheader("referer");         redirectview redirectview = new redirectview(referrer);         redirectview.addstaticattribute("errormessage","execute query retry");         return redirectview;     } 

view

<label id="errormessage" name="errormessage">${errormessage}</label> 

you can referer , forward or redirect it. e.g.

@exceptionhandler(httpsessionrequiredexception.class) public string (httpservletrequest request) {     string referrer = request.getheader("referer");     ...     flashmap flashmap = requestcontextutils.getoutputflashmap(request); flashmap.put("errormessage","execute query retry");     return "redirect:/my/url"; } 

the redirect url relative application path. can extract referer.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -