don't dream your life, live your dreams !
Please read : Java spring – quickstart
You can add the following Bean. This will redirect all ‘java.lang.Exception’ in the ‘/error’ viewer :
@Bean(name="simpleMappingExceptionResolver") public SimpleMappingExceptionResolver createSimpleMappingExceptionResolver() { SimpleMappingExceptionResolver simpleMappingExceptionResolver = new SimpleMappingExceptionResolver(); Properties mappings = new Properties(); mappings.setProperty("java.lang.Exception", "/error"); simpleMappingExceptionResolver.setExceptionMappings(mappings); return simpleMappingExceptionResolver; } |
${exception} is added to the context.
You can print the exception message :
${exception.message} |
And the stack strace :
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<b>Stack trace:</b><br>
<ul>
<c:forEach var="entry" items="${exception.stackTrace}" >
<li>${entry}</li>
</c:forEach>
</ul> |
Copyright © 2025 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.
admin