In your webmvc-config.xml
set defaultStatusCode
property on org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
.
Example:
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:defaultErrorView="uncaughtException">
<property name="exceptionMappings">
<props>
<prop key=".DataAccessException">dataAccessFailure</prop>
<prop key=".NoSuchRequestHandlingMethodException">resourceNotFound</prop>
<prop key=".TypeMismatchException">resourceNotFound</prop>
<prop key=".MissingServletRequestParameterException">resourceNotFound</prop>
</props>
</property>
<property name="defaultStatusCode">
<value>500</value>
</property>
</bean>