KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > ModelAndViewDefiningException


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
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 JavaDoc {
36
37     private ModelAndView modelAndView;
38
39
40     /**
41      * Create new ModelAndViewDefiningException with the given ModelAndView,
42      * typically representing a specific error page.
43      * @param modelAndView ModelAndView with view to forward to and model to expose
44      */

45     public ModelAndViewDefiningException(ModelAndView modelAndView) {
46         Assert.notNull(modelAndView, "ModelAndView must not be null in ModelAndViewDefiningException");
47         this.modelAndView = modelAndView;
48     }
49
50     /**
51      * Return the ModelAndView that this exception contains for forwarding to.
52      */

53     public ModelAndView getModelAndView() {
54         return modelAndView;
55     }
56
57 }
58
Popular Tags