spring.xml
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<!-- exceptionMappings:配置哪些异常去哪些页面 -->
<property name="exceptionMappings">
<props>
<!-- key:异常全类名;value:要去的页面视图名; -->
<prop key="java.lang.NullPointerException">myerror</prop>
</props>
</property>
<!--指定错误信息取出时使用的key -->
<property name="exceptionAttribute" value="ex"></property>
</bean>
ExceptionTestController.java
@RequestMapping("/handle04")
public String handle04(){
System.out.println("handle04");
String str = null;
System.out.println(str.charAt(0));
return "success";
}