通常处理异常返回语言是以code以及message两种方式进行语句返回接下来就是对其两种进行分析
首先是由code方式进行将异常语句返回 首先创建工具类I18n
package com.seedeer.common.i18n;
import com.seedeer.common.util.ParamUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Locale;
/**
* @Description i18N工具类
@Component
public class I18NUtil {
@Autowired
private I18NMessageResource i18NMessageResource;
private static final String PDA_ZH_LANGUAGE = "zh_CN";
private static I18NUtil i18NUtil;
@PostConstruct
public void init() {
i18NUtil = this;
i18NUtil.i18NMessageResource = this.i18NMessageResource;
}
public static boolean isChinese(){
if (StringUtils.equals(LocaleContextHolder.getLocale().getLanguage(), Locale.ENGLISH.getLanguage())) {