Note that there are some explanatory texts on larger screens.

plurals
  1. POerror handling with spring + servlet spec
    primarykey
    data
    text
    <p>I have a web-app (2.5 servlet spec) with a spring dispatcherservlet handling anything coming on /error/* and an error page configured to route that to /error/ something like this:</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;errorServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;errorServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/erorr/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;error-page&gt; &lt;exception-type&gt;java.lang.Throwable&lt;/exception-type&gt; &lt;location&gt;/erorr/&lt;/location&gt; &lt;/error-page&gt; </code></pre> <p>and the errorServlet-servelt.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt; &lt;context:annotation-config/&gt; &lt;context:component-scan base-package="some.base.package"/&gt; &lt;bean id="simpleUrlController" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt; &lt;property name="mappings"&gt; &lt;props&gt; &lt;prop key="/*"&gt;errorController&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="errorController" class="ErrorController"&gt; &lt;property name="formView" value="formView"/&gt; &lt;property name="commandClass" value="Error"/&gt; &lt;property name="commandName" value="errorNAMe"/&gt; &lt;/bean&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt; &lt;property name="suffix" value=".jsp"/&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>Spots I need help on: </p> <ol> <li>Whether this is the best approach to tackle errors.</li> <li>I know there is a SimpleMappingExceptionResolver which i can declare in my configuration...but i read somewhere that this class is good with only the exceptions coming from the spring controllers and not others.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload