|
|
|
@ -1,14 +1,6 @@
|
|
|
|
|
package cn.stylefeng.guns.core.error;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
|
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ErrorResponseData;
|
|
|
|
|
import cn.stylefeng.roses.kernel.rule.util.ResponseRenderUtil;
|
|
|
|
|
import org.springframework.web.servlet.View;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import org.beetl.ext.spring.BeetlSpringView;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 错误页面的默认跳转(例如请求404的时候,默认走这个视图解析器)
|
|
|
|
@ -16,17 +8,11 @@ import java.util.Map;
|
|
|
|
|
* @author fengshuonan
|
|
|
|
|
* @date 2017-05-21 11:34
|
|
|
|
|
*/
|
|
|
|
|
public class CustomErrorView implements View {
|
|
|
|
|
public class CustomErrorView extends BeetlSpringView {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getContentType() {
|
|
|
|
|
return "text/html";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void render(Map<String, ?> map, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
|
|
|
|
ErrorResponseData errorResponseData = BeanUtil.mapToBean(map, ErrorResponseData.class, true, CopyOptions.create().ignoreError());
|
|
|
|
|
ResponseRenderUtil.renderErrorResponse(httpServletResponse, errorResponseData.getCode(), errorResponseData.getMessage(), errorResponseData.getExceptionClazz());
|
|
|
|
|
return "text/html;charset=UTF-8";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|