-
Notifications
You must be signed in to change notification settings - Fork 209
/
mvc-configuration.xml
52 lines (44 loc) · 2.55 KB
/
mvc-configuration.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- This file shows how to configure a a SimpleMappingExceptionResolver
via XML configuration (which is how most developers are used to seeing it
done). The equivalent Java Configuration is in the ExceptionConfiguration
class -->
<!-- The use of the "xml-config" profile here is for demonstration only.
A real application wouldn't normally need to switch between XML or Java Configuration.
You would use one, or other, or both, all the time. -->
<beans profile="xml-config">
<!-- Configure a classic SimpleMappingExceptionResolver. Try using the
ExampleSimpleMappingExceptionResolver and see the difference when /unhandledException
is invoked. -->
<bean id="simpleMappingExceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<map>
<entry key="DatabaseException" value="databaseException" />
<entry key="InvalidCreditCardException" value="creditCardError" />
</map>
</property>
<!-- Override name of exception attribute. Default is 'exception'. -->
<property name="exceptionAttribute" value="ex" />
<!-- Name of logger to use to log exceptions. Unset by default, so logging
disabled -->
<property name="warnLogCategory" value="example.MvcLogger" />
<!-- Normally Spring MVC has no default error view and this class is the
only way to define one. A nice feature of Spring Boot is the ability to provide
a very basic default error view (otherwise the application server typically
returns a Java stack trace which is not acceptable in production). See Blog
for more details. -->
<!-- To stick with the Spring Boot approach, DO NOT set this property
of SimpleMappingExceptionResolver. -->
<!-- Here we are choosing to use SimpleMappingExceptionResolver since
many Spring applications have used the approach since Spring V1. Normally
we would specify the view as "error" to match Spring Boot, however so you
can see what is happening, we are using a different page. -->
<property name="defaultErrorView" value="defaultErrorPage" />
</bean>
</beans>
</beans>