001/*
002 * Copyright 2002-2010 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.servlet.handler;
018
019import java.util.Locale;
020import javax.servlet.http.HttpServletRequest;
021import javax.servlet.http.HttpServletResponse;
022
023import org.springframework.web.context.request.ServletWebRequest;
024import org.springframework.web.servlet.support.RequestContextUtils;
025
026/**
027 * {@link ServletWebRequest} subclass that is aware of
028 * {@link org.springframework.web.servlet.DispatcherServlet}'s
029 * request context, such as the Locale determined by the configured
030 * {@link org.springframework.web.servlet.LocaleResolver}.
031 *
032 * @author Juergen Hoeller
033 * @since 2.0
034 * @see #getLocale()
035 * @see org.springframework.web.servlet.LocaleResolver
036 */
037public class DispatcherServletWebRequest extends ServletWebRequest {
038
039        /**
040         * Create a new DispatcherServletWebRequest instance for the given request.
041         * @param request current HTTP request
042         */
043        public DispatcherServletWebRequest(HttpServletRequest request) {
044                super(request);
045        }
046
047        /**
048         * Create a new DispatcherServletWebRequest instance for the given request and response.
049         * @param request current HTTP request
050         * @param response current HTTP response
051         */
052        public DispatcherServletWebRequest(HttpServletRequest request, HttpServletResponse response) {
053                super(request, response);
054        }
055
056        @Override
057        public Locale getLocale() {
058                return RequestContextUtils.getLocale(getRequest());
059        }
060
061}