01: /*
02: * Copyright 2002-2007 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.bind;
18:
19: /**
20: * {@link ServletRequestBindingException} subclass that indicates a missing parameter.
21: *
22: * @author Juergen Hoeller
23: * @since 2.0.2
24: */
25: public class MissingServletRequestParameterException extends
26: ServletRequestBindingException {
27:
28: private String parameterName;
29:
30: private String parameterType;
31:
32: /**
33: * Constructor for MissingServletRequestParameterException.
34: * @param parameterName the name of the missing parameter
35: * @param parameterType the expected type of the missing parameter
36: */
37: public MissingServletRequestParameterException(
38: String parameterName, String parameterType) {
39: super ("");
40: this .parameterName = parameterName;
41: this .parameterType = parameterType;
42: }
43:
44: public String getMessage() {
45: return "Required " + this .parameterType + " parameter '"
46: + this .parameterName + "' is not present";
47: }
48:
49: /**
50: * Return the name of the offending parameter.
51: */
52: public String getParameterName() {
53: return this .parameterName;
54: }
55:
56: /**
57: * Return the expected type of the offending parameter.
58: */
59: public String getParameterType() {
60: return this.parameterType;
61: }
62:
63: }
|