001/*
002 * Copyright 2002-2020 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.multipart.support;
018
019import javax.servlet.ServletException;
020
021import org.springframework.web.multipart.MultipartResolver;
022
023/**
024 * Raised when the part of a "multipart/form-data" request identified by its
025 * name cannot be found.
026 *
027 * <p>This may be because the request is not a multipart/form-data request,
028 * because the part is not present in the request, or because the web
029 * application is not configured correctly for processing multipart requests,
030 * e.g. no {@link MultipartResolver}.
031 *
032 * @author Rossen Stoyanchev
033 * @since 3.1
034 */
035@SuppressWarnings("serial")
036public class MissingServletRequestPartException extends ServletException {
037
038        private final String requestPartName;
039
040
041        /**
042         * Constructor for MissingServletRequestPartException.
043         * @param requestPartName the name of the missing part of the multipart request
044         */
045        public MissingServletRequestPartException(String requestPartName) {
046                super("Required request part '" + requestPartName + "' is not present");
047                this.requestPartName = requestPartName;
048        }
049
050
051        /**
052         * Return the name of the offending part of the multipart request.
053         */
054        public String getRequestPartName() {
055                return this.requestPartName;
056        }
057
058}