01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.web.servlet;
18:
19: import javax.servlet.ServletException;
20:
21: import org.springframework.util.Assert;
22:
23: /**
24: * Exception to be thrown on error conditions that should forward
25: * to a specific view with a specific model.
26: *
27: * <p>Can be thrown at any time during handler processing.
28: * This includes any template methods of pre-built controllers.
29: * For example, a form controller might abort to a specific error page
30: * if certain parameters do not allow to proceed with the normal workflow.
31: *
32: * @author Juergen Hoeller
33: * @since 22.11.2003
34: */
35: public class ModelAndViewDefiningException extends ServletException {
36:
37: private ModelAndView modelAndView;
38:
39: /**
40: * Create new ModelAndViewDefiningException with the given ModelAndView,
41: * typically representing a specific error page.
42: * @param modelAndView ModelAndView with view to forward to and model to expose
43: */
44: public ModelAndViewDefiningException(ModelAndView modelAndView) {
45: Assert
46: .notNull(modelAndView,
47: "ModelAndView must not be null in ModelAndViewDefiningException");
48: this .modelAndView = modelAndView;
49: }
50:
51: /**
52: * Return the ModelAndView that this exception contains for forwarding to.
53: */
54: public ModelAndView getModelAndView() {
55: return modelAndView;
56: }
57:
58: }
|