org.cattleframework.webmvc.exception.ExceptionController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cattle-webmvc Show documentation
Show all versions of cattle-webmvc Show documentation
Cattle framework webmvc component pom
The newest version!
/*
* Copyright (C) 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.cattleframework.webmvc.exception;
import org.cattleframework.exception.web.ExceptionProcessCustomizer;
import org.cattleframework.web.WebConstants;
import org.cattleframework.web.WebProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
* 异常Controller
*
* @author orange
*
*/
@Controller
@RequestMapping("${server.error.path:${error.path:/error}}")
public class ExceptionController implements ErrorController {
private final ErrorAttributes errorAttributes;
private final WebProperties webProperties;
private final ExceptionProcessCustomizer[] exceptionProcessCustomizers;
@Value("${" + WebConstants.PAGE_USE_TEMPLATE + ":false}")
private boolean pageUseTemplate;
public ExceptionController(ErrorAttributes errorAttributes, WebProperties webProperties,
ExceptionProcessCustomizer[] exceptionProcessCustomizers) {
this.errorAttributes = errorAttributes;
this.webProperties = webProperties;
this.exceptionProcessCustomizers = exceptionProcessCustomizers;
}
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
return ExceptionHandlerUtils.getExceptionModelAndView(request, response, errorAttributes, webProperties, true,
pageUseTemplate, exceptionProcessCustomizers);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy