Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2009-2018 Wudao Software Studio(wudaosoft.com)
*
* 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 com.wudaosoft.commons.mvc.handler;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.PropertyAccessException;
import org.springframework.core.MethodParameter;
import org.springframework.core.OrderComparator;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.method.ControllerAdviceBean;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import com.wudaosoft.commons.mvc.ReturnData;
import com.wudaosoft.commons.mvc.exception.ParameterException;
import com.wudaosoft.commons.mvc.exception.ServiceException;
import com.wudaosoft.commons.mvc.i18n.RestErrorI18N;
/**
* @author Changsoul Wu
*
*/
public class JsonXmlExceptionHandlerExceptionResolver2 extends
ExceptionHandlerExceptionResolver {
private static final Logger logger = LoggerFactory.getLogger(JsonXmlExceptionHandlerExceptionResolver2.class);
private static final String DEFAULT_EXCEPTION_ATTRIBUTE = "exception";
private static final String XML_STR = ".xml";
private static final String XML_STR1 = "xml";
private static final String XML_FORMAT_STR = "format";
private static final char SP_CHAR = '/';
private static final ReturnData DEFAULT_ERROR = new ReturnData(-1, "unknown error");
private static final ReturnData NOT_FOUND_ERROR = new ReturnData(404, "not found");
private static final ModelAndView NOT_FOUND_VIEW = new ModelAndView(JsonXmlExceptionHandlerExceptionResolver2.class.getName() + ".not_found_view");
private static final ReturnData PARAMETER_ERROR = new ParameterException().getReturnData();
private final static String APPLICATION_JSON_VALUE = "application/json; charset=utf-8";
private final static MediaType APPLICATION_JSON_UTF8 = MediaType.valueOf(APPLICATION_JSON_VALUE);
private final static String APPLICATION_XML_VALUE = "application/xml; charset=utf-8";
private final static MediaType APPLICATION_XML_UTF8 = MediaType.valueOf(APPLICATION_XML_VALUE);
private final List