001/*
002 * Copyright 2002-2017 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.reactive.result.view.freemarker;
018
019import org.springframework.web.reactive.result.view.UrlBasedViewResolver;
020
021/**
022 * A {@code ViewResolver} for resolving {@link FreeMarkerView} instances, i.e.
023 * FreeMarker templates and custom subclasses of it.
024 *
025 * <p>The view class for all views generated by this resolver can be specified
026 * via the "viewClass" property. See {@link UrlBasedViewResolver} for details.
027 *
028 * @author Rossen Stoyanchev
029 * @since 5.0
030 */
031public class FreeMarkerViewResolver extends UrlBasedViewResolver {
032
033        /**
034         * Simple constructor.
035         */
036        public FreeMarkerViewResolver() {
037                setViewClass(requiredViewClass());
038        }
039
040        /**
041         * Convenience constructor with a prefix and suffix.
042         * @param suffix the suffix to prepend view names with
043         * @param prefix the prefix to prepend view names with
044         */
045        public FreeMarkerViewResolver(String prefix, String suffix) {
046                setViewClass(requiredViewClass());
047                setPrefix(prefix);
048                setSuffix(suffix);
049        }
050
051
052        /**
053         * Requires {@link FreeMarkerView}.
054         */
055        @Override
056        protected Class<?> requiredViewClass() {
057                return FreeMarkerView.class;
058        }
059
060}